KVC访问非属性变量
kvcs是否可以访问非属性变量,答案是可以的.
@interface ModelDemo : NSObject { //@private NSString *demoString; } @end
ModelDemo *demo = [[ModelDemo alloc] init]; [demo setValue:@"Demo" forKey:@"demoString"]; NSLog(@"%@",[demo valueForKey:@"demoString"]);
不会出现crash.即使加上@private.同样可以访问.