Reputation: 824
When I start this iphone app is throws this error in the output console:
-[__NSCFString stringValue]: unrecognized selector sent to instance 0x548ad0
and crashes with this Thread kill:
libsystem_kernel.dylib`__kill:
0x360c0840: mov r12, #37
0x360c0844: svc #128
>> 0x360c0848: blo 0x360c0860 ; __kill + 32
What is the best way to debug this so I can see where in the code the problem lays?
Upvotes: 0
Views: 1094
Reputation: 952
The error message “unrecognized selector sent to instance XXX” means that the app is trying to call a method that doesn’t exist. Often this happens because the method’s being called on the wrong object. Here, the object in question is NSString (located at memory address 0x548ad0) and the method is stringValue:
To figure out where in the code this error occurred. You need to find the name of the source file and the number of the line that’s misbehaving. You can do this using the call stack (also known as the stacktrace or the backtrace).
if we keep the break points,Whenever the app crashes, the left pane of the Xcode window switches to the Debug Navigator. It shows the threads that are active in the app, and highlights the thread that crashed.
Upvotes: 0
Reputation: 469
select the break point navigator, which is the 2nd last selection on your xcode navigation bar (on the left side of the screen)
there's a + sign at the left bottom, click and select add exception breakpoint. tick exception breakpoint, exception: ALL, break: on throw, action: add action. (which should be the default selections anyway). click add, and your program should now stop at where the exception happens.
Upvotes: 2
Reputation: 31016
1) In Xcode, use the Breakpoint Navigator to set a breakpoint on Objective-C exceptions.
2) Look for places where you use stringValue
and check that you're using the right type of object. (It says you've called it on a string; it should be something else maybe a NSNumber
?)
3) Enable zombies in case the thing you think was getting the stringValue
message has been deallocated early.
Upvotes: 0
Reputation: 26907
You are trying to call stringValue
method on NSString
object. This will not work. You have not posted any code, but i assume you do something like that:
NSString *str1 = <#you get your string from somewhere#>;
NSString *str2 = [str1 stringValue]; //crash
To localize the crash, set up an exception breakpoint or just look for stringValue
calls in your project.
Upvotes: 0