ARC编译器是否根据属性属性自动确定在重写的类中保留还是分配?
我不太了解汇编程序,无法理解整个项目的汇编如此复杂的代码,但我注意到,如果我将 strong
属性添加到属性中,则会显示 _objc_storeStrong
调用靠近我的二传手的线,在那里我可以正确地改变自己的位置;
@interface ClassName : NSObject
@property (strong, nonatomic) NSSet *mySet;
@end
@implementation ClassName
@synthesize mySet;
-(void)setMySet:(NSSet *)newMySet
{
mySet = newMySet;
//do stuff
}
@end
所以?我说得对吗? ARC编译器是否根据属性属性自动确定在重写的类中保留还是分配?
I don't know assembler well enough to understand so complicated code as Assembly for whole project, but I noticed that if I put strong
attribute to the property, a _objc_storeStrong
call shows up near the line in my setter where I change my properly;
@interface ClassName : NSObject
@property (strong, nonatomic) NSSet *mySet;
@end
@implementation ClassName
@synthesize mySet;
-(void)setMySet:(NSSet *)newMySet
{
mySet = newMySet;
//do stuff
}
@end
So? am I right? Do the ARC compiler automatically determines whether to retain or assign in overridden class depending on property attributes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简而言之,是的。由于您将该属性设置为
strong
,因此该属性将被对象保留。如果将属性声明为weak
,则隐含(合成)变量为__weak NSSet *mySet
,并且不会保留该对象,但会 是一个自动归零指针。In short, yes. Because you set the property as
strong
, it will be retained by the object. If you declare the property asweak
, the implied (synthesized) variable is__weak NSSet *mySet
and that won't retain the object, but it will be a auto-zeroing pointer.