Originally Posted by jimpilot
Hi, I have just finished CH 6 of iPhone/Ipad App book and am enjoying not only the book but the excellent videos.
I am having a re-occurring problem in the implementation files (.m file) when I go to RUN after finishing I am finding the syntax checker wants me to rename fields from (for example); usernameField to _usernameField.
Due to this, the compiler does not complete and shows an error status.
I notice in the TRY completed solutions (which work fine) that the syntax checker wants the same fields renamed.
I am running OSX 10.8.2, and Xcode 4.6
any ideas please?
Hi Jim, and thank you for the nice comments about the book and videos.
What you are experiencing is the change from Xcode/iOS 5.1 to 6.x. in 5.x you could say:
In the *.h (interface) file:
@property (strong, nonatomic) NSString *name;
and in the *.m (implementation) file:
Then in you methods say.
name = @"Joe";
Now with 6.x you no longer need to @synthesize name; in the *.m file, however what is going on in the background is this:
So the reason that Xcode is asking for you to make it _name instead of name:
_name = @"Joe";
Is because of the default action that you are getting this error.
What I would suggest is to do it the way we did back in the NeXTSTEP days
or if you use dot notation instead of brackets:
self.name = @"Joe";
One thing to note is that when the book was originally started, iOS 5.0 was in beta so the text was written against that standard when the book would be released. The videos were created after the text was written, edited, approved and sent off to print. When the videos were being created, Apple was then beta testing iOS 5.1. Xcode once again changed a number of things. So some things will not exactly line up with the text.
When in doubt, please go to the video as the TryIt's step by step with 5.1 will still work with today's 6.1, while the text because of being based on 5.0, may differ with 6.1.
Thank you again for your feedback, I would have responded sooner, but I did not get a notification via email that this new post was created.
If you have any more questions, please append this thread, so I will get a notification and can respond promptly.