NSObjectFromString... Any way to do it?

object, objective-c, runtime, string

Solution

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.

Problem

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?

Original source