更新时间:2023-02-23 19:31:10
这里是你想要的:
Class theClass = NSClassFromString(classNameStr);
id myObject = [[theClass alloc] init];
请注意,您不能使用 theClass
作为类型名称(即 theClass * myObject
)。您必须使用 id
。
Note that you can't use theClass
as a type name (i.e. theClass *myObject
). You'll have to use id
for that.