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?
So Objective-C has these nice functions NSClassFromString() and NSProtocolFromString() , which return a class
Share
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.