财产申报中的含义atomic和nonatomic含义是什么?
@property(nonatomic, retain) UITextField *userName;
@property(atomic, retain) UITextField *userName;
@property(retain) UITextField *userName;
Run Code Online (Sandbox Code Playgroud)
这三者之间的运作区别是什么?
Obj-C 2.0中属性的文档说原子属性在内部使用锁,但它没有记录锁的具体内容.有没有人知道这是一个per-property锁,一个每个对象的锁与@synchronized(self)使用的隐式锁分开,还是等同于@synchronized(self)?
在合成属性方面我有点困惑.
让我们说我的*.h文件中有这个属性.
@property (nonatomic, retain) NSString *aString;
Run Code Online (Sandbox Code Playgroud)
在我的*.m文件中我合成它.@synthesize aString;
我知道当我使用synthesize时,编译器将生成setter和getter.但这些孵化器和吸气器是怎样的?
当我给aString一个值时,哪些方法是正确的?
self.aString = @"My New String"; // This will use the setter?
aString = @"My new String"; //This will not use the setter and retain the string, right?
aString = [@"My new string" retain]; //This will not use the setter, but it will retain the string ?
[self setAString:@"My new string"]; //This will also use the setter?
Run Code Online (Sandbox Code Playgroud)
提前致谢!
我有一个叫做dog的课,还有一个叫做cat的课.
Dog在.h文件中有@property声明的变量"name".
在cat类中,我在创建dog类型的变量"myDog"之后使用命令myDog.name ="buster"设置了名称.
当通过覆盖通常由@synthesize命令创建的set方法设置名称时,我想执行其他操作.
我怎样才能做到这一点?谢谢您的帮助!
objective-c ×3
iphone ×2
atomic ×1
cocoa ×1
ios ×1
ios4 ×1
ipad ×1
nonatomic ×1
properties ×1
xcode ×1