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 265(you need to either click on it a few times or drill down directly using the Document Outline) andopen the Size Inspector. Pull down the Size menu in the Control section and choose Small. Nowswitch to the Attributes Inspector to alter the nature of this field a little.The label will work best if it’s aligned to the right, placing the label text up against the value. Thebuttons next to the Alignment option here will let you make that change. Additionally, rather thangive every new field a default value of Table View Cell, delete its Title property and type “Label”into its Placeholder property.You also want to be able to edit labels in-place in a manner similar to the people table. To dothis, you need to change the behavior of the text field: further down the Attributes Inspector, pulldown the Behavior menu and choose Editable. This will give it the exact same behavior as theuser names you were able to edit earlier.The final step is to bind the value of the text field to the appropriate value from the data store:in the Bindings Inspector, bind the Value property to Table Cell View, with a Model Key Path ofobjectValue.label. The editor will likely claim that it can’t find any completions and place anexclamation mark in the Model Key Path’s field, but you can safely ignore that.You might notice that the label is now positioned a little higher within its cell than would beideal—its baseline doesn’t align nicely with the baseline of the larger text in the next column.Fortunately, Cocoa Autolayout makes this nice and easy to deal with. Unfortunately, this can’t bedone in the interface editor. You can select both text fields easily enough, but the editor doesn’tseem to recognize that it can create constraints between these two items. For now, take theeasy route and just move the label field down a little until it looks better: with the field selected,use the cursor keys on your keyboard to move it down a point at a time until you like the lookof it. I found that two points lower did the trick. Cocoa Autolayout will see that it stays in thatvertical position as the parent views resize. Again, repeat this for all three tables.On to the value columns: you’ll be doing things one way for the Phone and Email tabs, andsomething a little more complicated for the Addresses tab.For Phones and Emails, you won’t have to change much, as the control size and layout arealready how you want them. Replace their titles with placeholders of “Phone Number” and“Email,” respectively, and set their behavior to Editable as before. Then bind their values to theirTable Cell Views’ objectValue.phoneNumber or objectValue.email as appropriate. You’re nowdone with the first two types of address information. If you run the application, you should beable to browse that information properly, similar to that shown in Figure 8-11.www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!