Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

diyora

macrumors newbie
Original poster
Jul 21, 2008
25
0
Hello,
I want to know the object type in cocoa.
Suppose object (id) is consider in which i store string,int,etc..
But i want to know the type of (id).

Thank you...
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
id is simply void *. If you meant what is the class of object currently being pointed to you can simply ask it:

Code:
id someObject;
// Do something to point someObject at an object
NSLog(NSStringFromClass([someObject class])); // You can also ask for className directly
 

diyora

macrumors newbie
Original poster
Jul 21, 2008
25
0
id is simply void *. If you meant what is the class of object currently being pointed to you can simply ask it:

Code:
id someObject;
// Do something to point someObject at an object
NSLog(NSStringFromClass([someObject class])); // You can also ask for className directly

Thanks for your kind reply.

This is ok for NSString and like wise Class type.
But what aboout NSInteger, NSUInteger, etc. basic types?
It is not working with NSInteger.
Any other way?

Thanks.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
NSInteger etc are not objects and should not be assigned to id pointers. If you do so you run the risk of accessing them as objects. If you insist on storing them in this way there is no way of finding their type later.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.