Re: Any way to tell if a pointer is an object?
Re: Any way to tell if a pointer is an object?
- Subject: Re: Any way to tell if a pointer is an object?
- From: Jerry Krinock <email@hidden>
- Date: Sat, 24 Feb 2007 22:10:56 -0800
- Thread-topic: Any way to tell if a pointer is an object?
on 07/02/24 20:51, Ricky Sharp at email@hidden wrote:
> whereas 'theObjectPointer' did. For example, you should see a
> familiar class name in the 'name' field:
>
> (id)0x43aa50 0x43aa50
> isa 0x402910
> isa 0xa295fed8
> super_class 0xa295a3b8
> name 0xa295a3b8 NSCFArray
> ...
Thanks, Ricky. Indeed, I can see this in gdb.
Ah, but I should not have used the word "debug". I'm a lazy Cocoa
programmer; I don't do a debug build and fire up gdb unless I've got
something really gnarly going on. I should have asked this instead:
Is there any way to test whether or not a pointer points to an object before
sending it a message, to avoid the possible crash that will occur if it does
not point to an object?
For example, since documentation is not always complete, I often want to
examine the "(void*)contextInfo" that I get in a callback. Doing
NSLog(@"contextInfo = %@", contextInfo) ;
results in a crash if *contextInfo is not an object.
Jerry
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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