This App Crashes in iOS 5.1.1


#1

I was working through chapter 18. The segmented controls worked fine. But when I attempted to implement the code to set the segmented control default the app blows up on my iPhone 4S under iOS 5.1.1. I get this error:

2012-09-09 12:21:35.511 Whereami[7336:707] -[WhereamiViewController changeMaptype:]: unrecognized selector sent to instance 0x18aca0 2012-09-09 12:21:35.515 Whereami[7336:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[WhereamiViewController changeMaptype:]: unrecognized selector sent to instance 0x18aca0'

I played around with it for awhile to make sure everything I typed was fine and it was. So I gave up and loaded in the same app from the book’s code sample repository for Chapter 18 and it blows up to in exactly the same way.

…Dale


#2

Hi Dale,
first of all let me explain the error for you. It tells you that you send the message “changeMaptype:” to an instance of “WhereamiViewController” but you didn’t implement that method in “WhereamiViewController”.

The solution is:
You have a little typo in your message call. The “t” in “changeMap[color=#FF0000]T[/color]ype:” should be uppercase, but you sent the message “changeMap[color=#FF0000]t[/color]ype:”

Hope that helped you out.

Greetings
Joerg


#3

Three things: Thanks, Sorry once and Sorry twice JoergK!

The error message I copied below wasn’t the proper error message. That was an earlier error that I had fixed just as you indicated. Somehow each time I ran the app the NSLog wasn’t emptying. Hence I copied the prior error message and not the error message I got when it blew up.

The second Sorry above relates to the fact that something screwed up either in xCode or on my Mac that seems to have caused the problem. As I mentioned above both the one I typed in and the one I downloaded from the code repository and it blew up (but with a different error than the one I posted).

HOWEVER!!! I since writing the above, I subsequently rebooted my Mac and xCode and now when I run the Chapter 18 whereami app and my own, neither of them blow up any more. Nothing changed other than my restarting my Mac and Xcode. So I don’t know what happened.

LESSON LEARNED: If the downloaded sample code from BNR is blowing up, reboot the Mac and try again! :slight_smile:

…Dale