views:

66

answers:

2

So Objective-C has these nice functions NSClassFromString() and NSProtocolFromString(), which return a class or protocol from a passed string name. Is there any way to do this with an object?

+3  A: 

No, because objects don't have canonical names or string representations. With a class, there either is a class called "NSWindow" or there isn't. With objects, that correspondence doesn't really apply. If you're looking to serialize an object, check out the NSCoding protocol and accompanying documentation.

Chuck
+1, I suspect you're closer to the OP's intent than I.
John Rudy
A: 

The closest thing I can think of is -description, but I suspect you're looking more for introspection into all the members than the basic description. If you are, you're going with Chuck's answer, because you need to serialize/deserialize.

John Rudy