我一直在用我的.m文件合成对象:
@synthesize myObject;
如果我有很多物品,我会这样做:
@synthesize myObject1, myObject2, myObject3;
但是我看到有些人以这种方式合成:
@synthesize myObject = _myObject;
有人可以解释一下合成对象的更好方法吗?
答案 0 :(得分:0)
像这样: 答案1:
- (void)setCoolWord:(NSString *) myObject {
_myObject = myObject;
}
- (NSString *) myObject {
return _myObject;
}
希望它有所帮助。
with Xcode 4.5 or up. The IDE write the @synthesize statement for you.
The @synthesize statement is only write the setter and getter for you.
that, _variable_name is the instant variable.
The variable_name is only a method that returns the value of _variable_name by default.
when using the variable = <Statement or value>. its calling thesetVarable_Namemethod to set the_variable_name` by default.
答案 1 :(得分:0)
2. @ property(nonatomic,strong)NSString * fullName;
3.do in .m你希望在那里使用self或(_)编写这样的文字。