Second invocation of -postInformationToServer harmful?


#1

On pp. 482-83, the implementation of -application:didRegisterForRemoteNotificationsWithDeviceToken: includes an invocation of -postInformationToServer, and an explanation of why this is necessary is given on p. 486 in the section “Getting the token to the provider”. It all makes sense. The only problem is, it causes my app to crash!

-application:didRegisterForRemoteNotificationsWithDeviceToken: invokes -postInformationToServer, which invokes -serverHostName; its first two lines are:

    NSArray *addresses = [desktopServer addresses];
    NSData *firstAddress = [addresses objectAtIndex:0];

But the addresses array is empty, so that second line results in the crash.

I commented out this invocation of -postInformationToServer and continued on with the rest of the chapter with no problems or apparent ill effects. So maybe it’s unnecessary and even harmful? Thoughts?


#2

Check out the sticky in this forum for Chapter 29 Errata. It solves this problem.