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

liptonlover

macrumors 6502a
Original poster
Mar 13, 2008
989
0
1. Will (id *)aValue accept any type of data, including C variables?

2. I need to find out what kind of variable/data that id is... how do I do that?

Nate
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
I am 99% sure id cannot take a primitive, you'd have to wrap it in an NSNumber. Someone that's a little more familiar may want to chime in if this is incorrect, but id in my mind has to allow for type introspection, and primitives don't carry that sort of information.

Check out:
http://developer.apple.com/document...//apple_ref/occ/intfm/NSObject/isKindOfClass:
http://developer.apple.com/document...apple_ref/occ/intfm/NSObject/isMemberOfClass:
and
http://developer.apple.com/document...ect.html#//apple_ref/occ/intfm/NSObject/class

They describe methods that can be called on any NSObject to get its Class or see if it is an object of a particular type. It's not that this is particularly dangerous at all, but runtime introspection (or reflection in some other languages) does require care.

-Lee

P.S. Sometimes its just a matter of knowing what to call things. In this case, it's type/runtime introspection. The wikipedia article is actually pretty good on this topic:
http://en.wikipedia.org/wiki/Introspection_(computer_science)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.