Objective-C中属性修饰符copy,retain,assign,readonly,readwrite,nonatomic
2014-03-01 14:35
393 查看
Problem:
在Objective-C中,除了定义类的实例变量(instance variable)之外,还可以定义其属性。属性其实可以理解为类的一种变量,只不过声明为属性,可以使用@synthesize语法来自动合成变量的存取方法(getter
and setter methods)。属性的定义类似于:
@interface ClassA
@property (nonatomic, retain) UIButton *button;
@property (nonatomic, assign) int number;
@end
其中属性前面括号里面的为属性的修饰符,有atomic、nonatominc、readonly、readwrite、copy、retain、assign等(在ARC中,retain、assign分别为strong、weak)。那么这些修饰符怎么去理解,它们又有什么区别呢?
Solution:
Discussion:
(remain summarize)
在Objective-C中,除了定义类的实例变量(instance variable)之外,还可以定义其属性。属性其实可以理解为类的一种变量,只不过声明为属性,可以使用@synthesize语法来自动合成变量的存取方法(getter
and setter methods)。属性的定义类似于:
@interface ClassA
@property (nonatomic, retain) UIButton *button;
@property (nonatomic, assign) int number;
@end
其中属性前面括号里面的为属性的修饰符,有atomic、nonatominc、readonly、readwrite、copy、retain、assign等(在ARC中,retain、assign分别为strong、weak)。那么这些修饰符怎么去理解,它们又有什么区别呢?
Solution:
Discussion:
(remain summarize)
相关文章推荐
- (8)javascript 引用类型--Object类型
- object对象的比较
- 案例079 实现文件拖进拽出
- 案例217 播放本地MP3文件
- Objective-C命名风格
- 【Objective-C】多线程
- BNR:Objective-C Programming
- Effective Java 06 Eliminate obsolete object references
- 一些常见的debug错误
- AttributeError: 'module' object has no attribute 'Frame' 解决方法
- error C2504: 'CObject' : base class undefined
- Matlab报错BLAS loading error: dlopen: cannot load any more object with static TLS 处理办法
- 【C#开发iOS】Objective-C与C# with Xamarin的开发代码对比
- objective -c OC语法学习小结
- Multiple markers at this line - The type java.lang.Object cannot be resolve
- object.constructor
- DisplayObject等显示对象基类
- objective c 学习(一)
- iOS开发:详解Objective-C runtime
- Object转Integer