Re: Unable to access an instance properties and methods
Re: Unable to access an instance properties and methods
- Subject: Re: Unable to access an instance properties and methods
- From: Jens Alfke <email@hidden>
- Date: Wed, 19 Mar 2008 11:23:24 -0700
On 19 Mar '08, at 10:00 AM, Davide Benini wrote:
For some reason I had a placed a NSString instead of a DBNNote into
the array; probably for debugging purposes...
Thanks a million, I had zero chaces of tracing this bug by myself,
for I thought the description was the appropriate one...
Here's some advice on how to debug stuff like this in the future...
The exception message is a good clue:
2008-03-19 17:19:30.957 cocoabc[10832:10b] *** -[NSCFString
accident]: unrecognized selector sent to instance 0x33b040
This shows that the receiver of -accident was an NSCFString object.
The way I would track something like this down is, first, to set a
symbolic breakpoint on objc_exception_throw (via Xcode's breakpoints
window.) This is always a good thing to have. Then run the app in the
debugger and it'll hit the breakpoint when the exception's raised.
Now select the topmost application stack frame — it'll be on the line
that calls [firstNote accident]. Then you can enter "po firstNote" in
the debugger console to see the object's description. But as you
pointed out, it looks like the description of a DBNNote object even
though it's a string, so you can't really tell from that. A more
surefire test is to enter "po [firstNote class]", which will print
"NSCFString" instead of "DBNNote". That's your smoking gun.
The "po" and "p" commands are incredibly useful debugging tools, since
they let you make nearly any Objective-C call interactively on your
running code. Gdb understands a surprisingly large subset of Objective-
C syntax.
—Jens
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden