Objective-C and runtime type inspection

Joel Reymont joelr1@REDACTED
Thu Aug 17 19:35:10 CEST 2006


On Aug 17, 2006, at 6:15 PM, Ryan Rawson wrote:

> what structures?  There _are_ no structures to inspect... All you have
> is an opaque object reference that you can then send messages to.

What I mean is that you can use RTTI to find the signature of the  
function, including the argument types. For structures you get the  
field types. See the NSRange structure in the example signature below.

c24@REDACTED:4o^@8@REDACTED^{_NSRange=II}16o^@20

You can, technically, represent the function arguments as a tuple and  
just give all elements of a tuple to objc_msgSend but you will crash  
and burn if you pass some integer where a pointer is expected. An  
exception won't be forthcoming.

> Objective C is more like smalltalk than C++/Java/etc.  You cannot mess
> with the fields of an object.  They are 100% opaque (technically they
> are C structs, but you are asking for trouble to inspect them).

The object fields are not opaque, instance variables are available  
for inspection.

> Also, why doesn't your email thread up with the other message?

Works for me. I did change the subject to match the contents, though.

	Thanks, Joel

--
http://wagerlabs.com/








More information about the erlang-questions mailing list