Sample Code fails - The application Delegate


#1

I am following the sample code on page 183 under the section “The application Delegate”.

I getting a compiler error stating that the Control reaches the end of non-void function.

Here is the code I am using from the book - I can’t see a typo. It seems like this function should be returning a boolean and it doesn’t return anything? I am getting the error on the very last line of my pasted code with the closing curly bracket.

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    //Attempt to load an existing to-do dataset from an array stored to disk.
    NSArray *plist = [NSArray arrayWithContentsOfFile:docPath()];
    if (plist) {
    //If there was a dataset available, copy it into our instance variable.
    tasks = [plist mutableCopy];
    } else {
    //Otherwise, just create an empty one to get us started.
    tasks = [[NSMutableArray alloc] init];
    }
    }

I appreciate anyone’s time in looking at my problem and giving me some help.


#2

A return statement is required at the end of the function:

- (BOOL)application:(UIApplication *)application ...
{
    ...
    return YES;
}

#3

Thanks - I thought that might be the problem as well but there is no return statement in the book so… Maybe something they can fix on the next printing.


#4

Ack! Good catch. I’ve updated the materials and this’ll be fixed in the next printing. Thanks!