So Objective-C has these wonderful functions NSClassFromString()and NSProtocolFromString()that return a class or protocol from the passed string name. Is there a way to do this using an object?
NSClassFromString()
NSProtocolFromString()
No, because objects do not have canonical names or string representations. With the class, there is either a class called "NSWindow" or not. With objects this correspondence does not apply. If you want to serialize an object, see the NSCoding protocol and related documentation .
, , - -description, , , . , , /.
-description
If you want to instantiate an object, you can also do this
Class class = NSClassFromString(className); id object = [class new];
Source: https://habr.com/ru/post/1729501/More articles:Using STL Allocator with STL vectors - c ++Как создать индивидуальные представления для AppWidgets? - androidКак я могу предотвратить преобразование ASP.NET в символ & и добавление URL-адреса в атрибуты управления? - urlXMMS2: setting name change notifications - cSAP Portal with Third Site - portletHow to make Resharper show Refactoring that it is already - visual-studio-2008Saving default argument values in method chain - pythonDatabase Optimization: Hashing All Values - optimizationHow to assign value to a session using javascript - javascriptAsyncFileUpload has a logical error in AjaxControlToolkit when the component is on a different tab, therefore it is not displayed - javascriptAll Articles