Property attributes
来源:互联网 发布:免费胸卡制作软件 编辑:程序博客网 时间:2024/05/17 06:14
There are many attributes for property as follows:
- atomic:
- Is default behavior
- will ensure the present process is completed by the cpu, before another process access the variable
- not fast, as it ensures the process is completed entirely
- nonatomic:
- Is NOT default behavior
- faster (for synthesized code, ie for variable created using @property, @synthesize )
- not thread safe
- may result in unexpected behavior, when two different process access the same variable at the same time
- copy: is required when the object is mutable. Use this if you need the value of the object as it is at this moment, and you don't want that value to reflect any changes made by other owners of the object. You will need to release the object when you are finished with it because you are retaining the copy. For attributes whose type is an immutable value class that conforms to the
NSCopying
protocol, you almost always should specifycopy
in your@property
declaration.
- retain: is required when the attribute is a pointer to an object. The setter generated by
@synthesize
will retain (aka add a retain count to) the object. You will need to release the object when you are finished with it. By using retain it will increase the retain count and occupy memory in autorelease pool.
- strong: is a replacement for the retain attribute, as part of Objective-C Automated Reference Counting (ARC). In non-ARC code it's just a synonym for retain.
- weak: is similar to
strong
except that it won't increase the reference count by 1. It does not become an owner of that object but just holds a reference to it. If the object's reference count drops to 0, even though you may still be pointing to it here, it will be deallocated from memory.
- assign: is somewhat the opposite to
copy
. When calling the getter of anassign
property, it returns a reference to the actual data. Typically you use this attribute when you have a property of primitive type (float, int, BOOL...)
- Property attributes
- @property (attributes) 迷惑的attributes
- @property attributes 比较
- Property Declaration Attributes
- Reading Property Attributes
- Variable property attributes or Modifiers in iOS
- Variable property attributes or Modifiers in iOS
- Variable property attributes or Modifiers in iOS
- Objective-C declared @property attributes (nonatomic, copy, strong, weak)
- Object-c:Property Attributes && Variable life time Qualifiers
- IOS Dev Intro - Variable property attributes or Modifiers in iOS
- Unity Editor 基础篇(七):Property Attributes自定义属性
- Attributes
- Attributes
- $$Attributes
- jquery中.prop()和.attr()的区别 什么叫布尔型属性 property vs attributes , boolean attributes...
- html 中的属性(property)以及DOM对象中的attributes的详解
- Attributes.add
- c# static的全部用法收集整理(转载)
- php 常用类整理
- 简明VIM使用学习
- Android Push
- 消息内容定义XML
- Property attributes
- 这是我第一篇博文
- 存储器映射文件
- 树结构的遍历
- SQLite使用小例
- Extjs中Form页面隐藏存值修改
- 性能
- http://hi.baidu.com/xogjghsfhjemorr/item/5aab56f5f2f220ed1b111f5c
- linux 前台进程 后台进程