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: Ricky Sharp <email@hidden>
- Date: Sat, 24 Feb 2007 22:51:19 -0600
On Feb 24, 2007, at 10:19 PM, Jerry Krinock wrote:
When debugging, sometimes I get a pointer that may or may point to an
object. I would like to know what it is. If I send a message such as
-description to it, and my app crashes, I conclude that, "Gee, I
guess it
does not point an object".
Is there a less destructive and more satisfying way to find out
whether or
not an arbitrary pointer points to an object?
You can always attempt to view the pointer as an id.
For example, when doing the following...
int theInt = 333;
void* theObjectPointer = (void*) [NSArray array];
void* theIntPointer = &theInt;
I was able to view both pointers as an id. The data displayed by
'theIntPointer' of course didn't contain any recognizable data,
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
...
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
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