13.07.2015 Views

Beginning Objective-C pdf - EBook Free Download

Beginning Objective-C pdf - EBook Free Download

Beginning Objective-C pdf - EBook Free Download

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 8: Data Management with Core Data 257To create these controllers, look to the Object Library and select “Objects and Controllers” fromthe pop-up menu. Scroll down a little to find the Array Controller object and drag four of theseonto the object palette to the left of the editor, below the existing blue cubes representing otherobjects in the nib.At the moment they all have identical names: Array Controller. This isn’t very descriptive, sochange them: at the bottom left of the interface editor is a button with what looks like a commonPlay symbol, shown in Figure 8-6. This replaces the simple palette on the left of the editor with afull document outline.Figure 8-6. The Document Outline buttonNow you can change the names of your array controllers. Simply select each one and theneither click its name a second time (not a double-click) or press the Enter key. Name thefour controllers People Controller, Phones Controller, Emails Controller, and AddressesController, respectively.Note Due to a bug in Xcode, the names will seem to revert back to their original state whenyou press Enter to complete your edit. This is just a visual flaw, however: close and reopen theDocument Outline and you’ll see that your names have indeed been applied.Wire them up to the data from the managed object context, starting with the People Controller.Select that controller and in the Attributes Inspector change its mode to Entity Name. Belowthat, type Person as the entity name itself. Also check the Prepares Content and Auto RearrangeContent checkboxes, then switch to the Bindings Inspector.You need to bind one thing: the Managed Object Context. The actual content of the arrayis fetched automatically from this context: it fetches all instances of the Person entity fromthe store, so you don’t need to worry about the Content Set or Content Array bindings forthis controller.Bind the controller’s Managed Object Context parameter to the app delegate’smanagedObjectContext property, and then repeat this step for the other three controllers.You’re not done with those controllers yet, though: in their case, you want to bind theircontent to depend upon the currently selected Person object.www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!