Page 43


#1

Near the end of page instead of :

#import <UIKit/UIKit.h>

it should read

#import <Foundation/Foundation.h

Explanation:
When you make new class it defaults to foundation, not UIKit.


#2

I’m on Xcode 4 and interestingly enough the #import <UIKit/UIKit.h> was missing when I opened the file. I actually wrote it in at first and then when I flipped to Page 44 I noticed that it was replaced by #import <Foundation/Foundation.h>. I left both in until I tried to Build a received a nasty error and proceeded to delete this line.

I found something else that would be useful to point out around the same portion of the book (2nd Ed.). On Page 41, the reader is instructed to create a new subclass of NSObject by going to File > New > New File> Cocoa Touch. I’ll save my long sad story of spending an hour of trying to figure out why the Build option was greyed out and skip right to the helpful stuff: you need to create the NSObject subclass while you have the RandomPossessions project open on your screen. I finally found out my answer by Googling: “Xcode 4 won’t build Possession.h” and found http://forums.bignerdranch.com/viewtopic.php?f=44&t=652.

Why do I point this out? Because if you have to break often while reading through the chapters and you happen to break between projects then you may miss the flow. I had created RandomPossessions a couple of nights ago and since it was midnight I shut everything down and went to bed figuring I would work on the next project later. When I opened the book today to begin the subclass project, my mind didn’t connect the two as being related so I started a new file from the Organizer screen as if it were it’s own project. If you are reading this and you happen to have done the same thing you can easily correct the issue without rewriting everything: open RandomPossessions, from the Project navigator right-click the project heading: RandomPossessions, click Add files to RandomPossessions, then you will be able to select your Possession.h and Possession.m files (provided you know where they saved) and set your target as discussed on Page 43.

I know this may sound ridiculous to some of the experienced users; however, I’m a beginner and I know there has to be other beginners who may have made the same mistake. :wink:


#3

I got bit by this UIKit/Foundation discrepancy as well. Kicked my bottom for quite some time. The build settings showed it was building for Mac OS X (since we started with the Foundation tool in the Mac section) but the Framework Search Paths pointed (only) to iPhone.

The first edition stuck with the Mac section (pages 29-30); dunno why the second edition switched to iOS.