Objective-C class type error -
i have view created following:
class myclass = nsclassfromstring(classname); uiview *myview = [[myclass alloc] initwithframe:..]; the above works, hoping know if possible replace uiview , create instance this:
myclass *myview = [[myclass alloc] initwithframe:..]; ? gives error:
use of undeclared identifier myview
why can use this? , how can use way?
so tried:
const char *class = [myclass utf8string]; class myclass = objc_allocateclasspair([uiview class], class, 0); myclass *myview = [[myclass alloc] initwithframe:..]; but doesn't work. doesn't give above warning when subsequently do:
myview.backgroundcolor = ....; use of undeclared identifier myview
how can able use class type dynamically? , difference between:
nsclassfromstring(classname); and:
objc_allocateclasspair ?
use
class myclass = nsclassfromstring(classname); id myview = [[myclass alloc] initwithframe:..]; [myview setbackgroundcolor:[uicolor redcolor]]; but compile if try to
[myview addobject:...]; and crash.
Comments
Post a Comment