不知道能不能实现自动添加实例变量?好像以前在哪儿看过现在不用手动加了。请知道的人教教我,谢谢。
.h:
@interface Class : UIView
@property (nonatomic, strong) NSString *testString;
@end
.m:
@interface Class () {
NSString *_testString;
}
@end
@implementation Class
@synthesize testString = _testString;
解决方法:
h:
@interface Class : UIView
@property (nonatomic, strong) NSString *testString;
@end
.m:
@implementation Class
@end
@property
现在已经可以自动创建实例变量,而 @synthesize
在一般情况是自动添加的。所以用@property 可以实现