Is it possible to declare a variable type from string?
ios, objective-c
Solution
You should make the ivar of `id` type, and then make it dynamically typed. For example, if you want to dynamically type it `NSString`, you can do like this :
id ivar;
Class myClass = NSClassFromString(@"NSString");
ivar = [[myClass alloc] initWithString:@"abc"];
Problem
I don't know the technical term for this.I am wondering in Objective C, if it is possible to declare a variable like this: ``` NSClassFromString(aClassName) *var; ``` or ``` [NSClassFromString(aClassName) class] *var; ``` Apparently, the above two are not correct. What I want is to dynamically declare a variable. Thanks.