@synthesize w/iOS6 and Xcode 4.5


#1

After configuring properties for HomepwnerItemCell on page 302, the book says: “You can also see in HomepwnerItemCell.m that making a property outlet connection automatically adds a @synthesize statement for the property.” This is not the case with iOS6 and Xcode 4.5. Should these be done manually in this case, or will all magically be okay without them?


#2

I had the same question…


#3

In a possibly related problem, I manually created the @synthesize statements for nameLabel, serialNumberLabel, and valueLabel in HomepwnerItemCell.m. However, the code in tableView:cellForRowAtIndexPath: in ItemsViewController.m (where the setters for cell are being used to set text) accepts nameLabel just fine, but rejects serialNumberLabel and valueLabel with the message “No visible @interface for ‘HomepwnerItemCell’ declares the selector…”. Also, nameLabel is the only property (of the three mentioned) that auto-completes when typing.

I’ve tried combining all the @synthesize statements into one, I’ve re-checked spelling at least a dozen times. Any suggestions would be greatly appreciated.


#4

In Xcode 4.5 they are synthesised by default, however they are not actually placed into the implementation file.

To access them you use the underscore character beforehand, for instance say you had a property:

to use this in the implementation you would do

Nick
http://myfirstiphoneapp.co.uk
http://easyintervalsapp.co.uk


#5

Ah. Sneaky synthesis. Hmm.

Also, I tracked down the solution to my odd problem where one property responds to auto-complete properly, but the others do not. Due to a failed attempt to create the class previously, I had an old copy of the .m file elsewhere in the project hierarchy. I discovered this by using right-click “Show in Finder” and then looking around a bit. Even though XCode was showing one file for editing when I clicked on that file name, it was using the other for syntax checking and the build. Once I deleted the old file, everything was fine.

So, if things are behaving oddly and don’t make sense according to the code you see on the screen, and you’ve had a previous attempt at the class and thought you deleted files, go into Finder and see if there are duplicates laying around.