void reflect() {spa
//類名的反射,字符串變成Classorm
NSString *str = @"Person";字符串
Class class = NSClassFromString(str);it
Person *person = [[class alloc] init];form
NSLog(@"%@",person); class
//Class變成字符串。test
NSString *name = NSStringFromClass([Person class]);select
NSLog(@"%@",name);反射
//方法的反射。方法
NSString *method = @"test";
SEL selector = NSSelectorFromString(method);
[person performSelector:selector];
[person release];
//將SEL轉換爲字符串
NSString *selectorName = NSStringFromSelector(selector);
NSLog(@"%@",selectorName);
}