Create object from NSString of class name in Objective-C

后端 未结 1 1266
心在旅途
心在旅途 2020-12-13 06:12

I was wondering if i could create a object of some class if i have the name of the class in a NSString. I know this is possible in other languages like ActionScript, C# and

相关标签:
1条回答
  • 2020-12-13 06:28

    Classes are first-class objects in Objective-C too. You can get the class object from an NSString with the NSClassFromString function.

    [[NSClassFromString(className) alloc] init...]
    
    0 讨论(0)
提交回复
热议问题