Steps to create an example Xcode-based application project based on basic data, storyboards, NSArrayController, NSTableView, and bindings.
Step 1 Create an Xcode Project. Select the OS X Cocoa Application and select Use Storyboards, Create Document Based Application, and Use Master Data.
Step 2 Select a data model. Add the entity "Character Name and String Attributes" and "Address".
Step 3 Select Main.storyboard. Add an NSArrayController to the view controller scene. Set the "Object Name" mode and set the name of the "Person" object. Check the box next to βPrepare content. Bind the Managed Object Context array controller to the View Controller , the key path of the model is representedObject.managedObjectContext .
Step 4 Go to the scene view of the view controller. Delete 'Your document content here. Add NSTableView. Bind Content to Array Controller , the controller's arrangedObjects key. Bind Selection Indexes to the Array Controller , the selectionIndexes key. Bind Sort Descriptors to the Array Controller , the sortDescriptors controller sortDescriptors .
Step 5 Bind the Value text fields in the table view to Table Cell View , the model key path of objectValue.name and objectValue.address . Check the box "Conditionally assign editable".
Step 6 Add two buttons "Add" and "Delete in the scene view controller view". Connect the actions to the add: and remove: actions of the array controller.
Step 7 (Objective-C) Select Document.h. In the makeWindowControllers method makeWindowControllers replace the [self addWindowController:β¦ with
NSWindowController *aWindowController = [[NSStoryboard storyboardWithName:@"Main" bundle:nil] instantiateControllerWithIdentifier:@"Document Window Controller"]; [self addWindowController:aWindowController]; aWindowController.contentViewController.representedObject = aWindowController.document;
Step 7 (Swift) Select Document.swift. In the makeWindowControllers method, at the end after self.addWindowController(windowController) add
windowController.contentViewController!.representedObject = windowController.document
Step 8 Build, Run, Test.