Solution exercises question


#1

I’m using Xcode 4.1 on Lion.

Do the solutions only contain the parts of code that I should have changed when working through a chapter? Or are they the entire solution? The reason I ask is that the code generated for me appears to have added additional methods such as the following (chapter 4 - WhereamiAppDelegate.m):

#pragma mark - Core Data stack

/**
 Returns the managed object context for the application.
 If the context doesn't already exist, it is created and bound to the persistent store coordinator for the application.
 */
- (NSManagedObjectContext *)managedObjectContext
{
    if (__managedObjectContext != nil)
    {
        return __managedObjectContext;
    }
    
    NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
    if (coordinator != nil)
    {
        __managedObjectContext = [[NSManagedObjectContext alloc] init];
        [__managedObjectContext setPersistentStoreCoordinator:coordinator];
    }
    return __managedObjectContext;
}

I’m thinking that this is just Apple’s way of being helpful to developers and providing them methods that they may need.

Thank you,
Brian.


#2

You didn’t uncheck the box for Core Data when creating the project.


#3

I just recently decided to delve into iOS programming and since I have zero programming skills I was uncertain about paying the $99/year for the full Apple Developer license. I instead opted to enroll for the free version, buy the Big Nerd Ranch book, and see what happens. I have the latest version of Xcode as of 08/18/2011.

That being said, it is important to note that when I worked through Chapter 1 last night and followed the directions step-by-step I noticed that the check box for Core Data was missing when creating a project. Maybe there is a setting I missed flipping to give me this option or maybe the Xcode for the free license is different. I worked until midnight and I am at work now so I have yet to research and discover why there is a difference. When you do not uncheck the Core Data box, then Xcode creates more files for you than the Guide will show in their example pictures (additional header, method and XIB files). To be able to follow the example and avoid confusion, I deleted the additional files and had to also go into the remaining files and delete their references and declarations. For having no programming knowledge I did a great job because my first run at the Quiz app worked perfectly the first time!

If anyone has any knowledge as to why the check box might be missing from Xcode where it is displayed in the Guide’s example pictures I would appreciate it. I’d rather not have to tweak each new project and risk deleting critical information or upgrade to the paid Developer license until I have more confidence I will stick with it. I will continue to research and post an answer if I discover one.

As of right now, the only guaranteed drawback to having the unpaid Developer access is being unable to sign my apps and view them on my actual device. I can only run them through the simulator (or so I believe based on the info in the Guide). This means that for Chapter 1 I was not able to take a screenshot to use for a loading screen. Hopefully, the remaining drawbacks (if any) will be minimal.


#4

As a follow up to my own post, I discovered my problem! I stated that when I created the new project Quiz app I was not presented with the option of Core Data. This is because I did not follow directions!

Page 2 stated to begin a Window-based Application and I used the View-based Application. I owe this simple mistake to the tutorial session I had downloaded earlier which taught me how to create apps using View-based apps only and to the simple fact that I assumed. :blush:

I figured this out when I started chapter 4 and did follow directions to start a Windows-based application and noticed the Core Data check box was there.