[OC Foundation框架 - 18] Class

使用Class来创建实例
1         // 18.通过@"Ball"创建一个Ball实例(不可以使用[[Ball alloc] init]创建)
2         NSString *className = @"Ball";
3         Class class = NSClassFromString(className);
4         Ball *ball = [[class alloc] init];
5         ball.color = ColorWhite;
6         NSLog(@"通过class创建了一个Ball %@", ball);
 
Class 是结构体指针不是类,不要加*
 
posted @ 2015-05-19 19:58  *新星月-倪新生*  阅读(154)  评论(0编辑  收藏  举报