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