Xcode 可以有一个变量类对象声明

Xcode 可以有一个变量类对象声明,xcode,class,uitableview,declaration,Xcode,Class,Uitableview,Declaration,这是我的例子: UITableView *cell = [[MyCustomClass alloc] init]; 有没有一种方法可以改变“MyCustomClass”类,比如有这样一个方法: -(NSObject*)newMethod:(int)intNumber{ classVariable = someClass depending on intNumber UITableView *cell [[<<<classVariable>>> alloc

这是我的例子:

UITableView *cell = [[MyCustomClass alloc] init];
有没有一种方法可以改变“MyCustomClass”类,比如有这样一个方法:

-(NSObject*)newMethod:(int)intNumber{
 classVariable = someClass depending on intNumber
 UITableView *cell [[<<<classVariable>>> alloc] init];
 return cell;
}

我的目标是有一个方法,我可以发送上面代码所需的所有信息,即tableViw、stringidentifier、nibName和MyClassCell您可以使用
类获得类的

Class myclass = [MYClass class];
现在可以将
myclass
作为变量传递,并且可以在需要
Class
的地方使用它:

id myinstance = [[myclass alloc] init];

您可以在NSArray中放置类名甚至类,并使用索引:

NSArray *classes = [NSArray arrayWithObjects:[ClassOne class], [ClassTwo class], [C
[三级]、无]

id instance = [[(Class)[classes objectAtIndex:anIndex] alloc] init];
如果希望在运行时动态构造/使用类信息,可以使用NSClassFromString()函数:

id anObject = [[NSClassFromString(@"FooBar") alloc] init];
id anObject = [[NSClassFromString(@"FooBar") alloc] init];