• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Unable to access an instance properties and methods
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unable to access an instance properties and methods


  • Subject: Re: Unable to access an instance properties and methods
  • From: Randall Meadows <email@hidden>
  • Date: Wed, 19 Mar 2008 12:34:35 -0600

On Mar 19, 2008, at 12:23 PM, Jens Alfke wrote:

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.

I've gotten some messages that just gave an address, not a class name. I delightfully discovered that sending -class to the raw address was just as valid and useful. This may be a "duh" moment for some, but eye-opening to me, and has come in quite handy recently.


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.

I 2nd this recommendation.

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.

'po $eax' has become my friend lately as well. It displays the register that contains the exception object that's already been thrown, after you've already crashed._______________________________________________


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


References: 
 >Unable to access an instance properties and methods (From: Davide Benini <email@hidden>)
 >Re: Unable to access an instance properties and methods (From: "Julien Jalon" <email@hidden>)
 >Re: Unable to access an instance properties and methods (From: Davide Benini <email@hidden>)
 >Re: Unable to access an instance properties and methods (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: What is this invisible character?
  • Next by Date: [SOLVED] - Re: NSString may not respond.... -and What is this invisible character?
  • Previous by thread: Re: Unable to access an instance properties and methods
  • Next by thread: NSString may not respond....
  • Index(es):
    • Date
    • Thread