Post

Replies

Boosts

Views

Activity

Reply to how to implement a tableview.notification in Swift
Hi Claude, it is Swift code, this project shall be the twin of my objective-c what must close because of deprecation of OpenGL. The first what I want is getting access to managedObjects, I send you the AppDelegate : import Cocoa import CoreData @main class AppDelegate: NSObject, NSApplicationDelegate { @IBOutlet weak var arrayController: NSArrayController! @IBOutlet weak var tableView: NSTableView! @objc var currentManagedObject: [NSManagedObject]; // error: func myPrint() { if(arrayController != nil){ print(arrayController!) }else { print("arrayController is NIL") } if(tableView != nil){ print(tableView!) }else { print("tableView is NIL") } } var center = [NotificationCenter.default] [center.addObserver: self, selector:#selector(rowSelectionDidChange(_:)), name:Notification.Name( selectionDidChangeNotification), object:nil] // error: Expected declaration @objc func rowSelectionDidChange(_ notification: Notification){ if(arrayController != nil){ var selected:[] as Any var arranged:[] as Any // error : /* Consecutive statements on a line must be separated by ';' Insert ';' Expected element type Insert ' <#type#>' Expected expression */ selected: NSArray = [arrayController.selectedObjects]; arranged = [arrayController.arrangedObjects]; if((selected.count) >= 0){ // ... } } } func applicationDidFinishLaunching(_ aNotification: Notification) {} func applicationWillTerminate(_ aNotification: Notification) {} func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { return true} } I hope it helps you to help me
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’23
Reply to how to implement a tableview.notification in Swift
I corrected the notification and got error : [center.addObserver: self, selector:#selector(rowSelectionDidChange(_:)), name:Notification.Name( selectionDidChangeNotification), object:nil] // error: Expected declaration rowSelectionDidChange(_:) do not belong to tableView, it is the function I want to use if(arrayController != nil){ var selected:[] as Any var arranged:[] as Any /* error : Consecutive statements on a line must be separated by ';' Insert ';' Expected element type Insert ' <#type#>' Expected expression */ selected: NSArray = [arrayController.selectedObjects]; arranged = [arrayController.arrangedObjects]; } } ` p.s. please give me a link of your communication rules .
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’23
Reply to Mistake in OpenGLView:drawRect
I solved the problem, in reshape I changed glOrtho() to glfrustum(). I'm happy.
Topic: Graphics & Games SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to ArrayController is nil at Runtime after awakeFromNib
I replaced the NSArrayController from the object library and renamed the @property(strong)IBOutlet NSArrayController * vrArrayController; Now runs awakeFromNib only one time and the controller is nil.
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Nov ’23
Reply to Learning Metal with "UsingARenderPipelineToRenderPrimitives"
No Reply is a Reply too. ☹️
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jun ’23
Reply to how to implement a tableview.notification in Swift
Hi Claude, it is Swift code, this project shall be the twin of my objective-c what must close because of deprecation of OpenGL. The first what I want is getting access to managedObjects, I send you the AppDelegate : import Cocoa import CoreData @main class AppDelegate: NSObject, NSApplicationDelegate { @IBOutlet weak var arrayController: NSArrayController! @IBOutlet weak var tableView: NSTableView! @objc var currentManagedObject: [NSManagedObject]; // error: func myPrint() { if(arrayController != nil){ print(arrayController!) }else { print("arrayController is NIL") } if(tableView != nil){ print(tableView!) }else { print("tableView is NIL") } } var center = [NotificationCenter.default] [center.addObserver: self, selector:#selector(rowSelectionDidChange(_:)), name:Notification.Name( selectionDidChangeNotification), object:nil] // error: Expected declaration @objc func rowSelectionDidChange(_ notification: Notification){ if(arrayController != nil){ var selected:[] as Any var arranged:[] as Any // error : /* Consecutive statements on a line must be separated by ';' Insert ';' Expected element type Insert ' <#type#>' Expected expression */ selected: NSArray = [arrayController.selectedObjects]; arranged = [arrayController.arrangedObjects]; if((selected.count) >= 0){ // ... } } } func applicationDidFinishLaunching(_ aNotification: Notification) {} func applicationWillTerminate(_ aNotification: Notification) {} func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { return true} } I hope it helps you to help me
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’23
Reply to how to implement a tableview.notification in Swift
I corrected the notification and got error : [center.addObserver: self, selector:#selector(rowSelectionDidChange(_:)), name:Notification.Name( selectionDidChangeNotification), object:nil] // error: Expected declaration rowSelectionDidChange(_:) do not belong to tableView, it is the function I want to use if(arrayController != nil){ var selected:[] as Any var arranged:[] as Any /* error : Consecutive statements on a line must be separated by ';' Insert ';' Expected element type Insert ' <#type#>' Expected expression */ selected: NSArray = [arrayController.selectedObjects]; arranged = [arrayController.arrangedObjects]; } } ` p.s. please give me a link of your communication rules .
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’23
Reply to how to implement a tableview.notification in Swift
No framework, the projects I mentioned arose on Xcode 4.2, maybe a difference .
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’23
Reply to how to implement a tableview.notification in Swift
Edit: selector: #selector: ( NSTableView.rowSelectionDidChange(_:)), name:"NSTableViewSelectionDidChangeNotification", object: nil)
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’23
Reply to Playground do not respond .
My fault, the Reason is : Xcode 4 has the default "Automatically Run" and 14 has "Manually Run". Thank you for your reply.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’23
Reply to Swift newbie has a question about overriding class
Sorry, my mistake, I deleted the class, closed Xcode and began new, I got no error. Maybe the reason is that I use Sierra. In the near future I buy a new iMac, then I need your support again.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Mar ’23
Reply to callDisplayLists() do not show
Edit: The two lines list is fine too.
Replies
Boosts
Views
Activity
Jun ’22
Reply to OpenGLView frame moves from [-1,-1,1] to [0,0,0];
Hi, I solved the problem with trial and error. The octahedron in the top sight gave me limits and I changed [0,0,-10] to [-0.25,-0.25,-10];
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jun ’22