相关疑难解决方法(0)

Objective-C中的ivars和属性有什么区别

在objective-c中使用ivars和属性的这三种方式之间的语义差异是什么?

1.

@class MyOtherObject; 
@interface MyObject {
}
@property (nonatomic, retain) MyOtherObject *otherObj;
Run Code Online (Sandbox Code Playgroud)

2.

#import "MyOtherObject.h"
@interface MyObject {
    MyOtherObject *otherObj;
}
@property (nonatomic, retain) MyOtherObject *otherObj;
Run Code Online (Sandbox Code Playgroud)

3.

#import "MyOtherObject.h"
@interface MyObject {
    MyOtherObject *otherObj;
}
Run Code Online (Sandbox Code Playgroud)

properties objective-c instance-variables

81
推荐指数
2
解决办法
2万
查看次数