02 Feb 2011, 17:05
Generic-user-small

Ric Levy (21 posts)

Hi Tim,

The very last task in the book is to open MessageTapperAppDelegate.m and add some code to the method “applicationDidFinishLaunching:”, to set an initial default for the text that will be displayed when the user presses “Tap Me!”. But I cannot find this method anywhere!

I have tried adding the code to “application: didFinishLaunchingWithOptions:”, with no success, and I have tried making my own “applicationDidFinishLaunching:”, which also didn’t work.

Either I’ve missed something, or Apple have changed the default code since the book was written (in which case the book’s first error is on the very last page!). Can you tell me which, and if the method is no longer there, where I should put this code?

Thanks.

03 Feb 2011, 09:34
Generic-user-small

Ric Levy (21 posts)

I managed to work it out!

First, applicationDidFinishLaunching has been deprecated and replaced with the new method, so the code is indeed meant to go there - that’s obviously something that has happened since the book was written.

Second, the iPhone simulator does not reset when you reload - hence I was never seeing the default text. I had to select “Reset Content And Settings…” in the iPhone Simulator menu.

09 Feb 2011, 09:32
Generic-user-small

Tim Isted (105 posts)

Hi Ric, @applicationDidFinishLaunching:@ should still work, though yes since the advent of multitasking under iOS 4 (which appeared not long after the book went to press) new applications should use @application:didFinishLaunchingWithOptions:@. I’ll make sure this is updated for the next printing.

I’m not sure what you mean when you say “the iPhone simulator does not reset when you reload”… Each time you Build & Run from Xcode, you’ll be asked if you want to terminate the application in the simulator (from iOS 4, pressing the Home button no longer exits an app) before relaunching it. This should cause the new copy of the app to be installed in the simulator, replacing the old one, so that each time you add code, the new functionality appears on the next Build & Run.

I have run into issues where more than one copy of an app can appear in the Simulator; the old one isn’t deleted and replaced, and the whole system gets confused, running the old one, even though it thinks it’s running the new one, so you don’t see any of the changes you just implemented in code (I speak from bitter experience trying to work out why all the lines of code I just wrote didn’t change anything). If this happens in the future, you don’t need to “Reset Content and Settings…” for all the apps you have in the Simulator, you can use the iOS device style app deletion: press and hold the app’s icon in the Simulator home screen until it wiggles, then press the x to delete it.

02 Mar 2012, 05:52
Generic-user-small

ginger rhain (1 post)

This method is used in earlier versions of iOS to initialize the application and prepare it to run. In iOS 3.0 and later, you should use the application:didFinishLaunchingWithOptions: instead. cheap auto insurance

  You must be logged in to comment