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 specify copy 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 an assign 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...)

A reference: http://www.raywenderlich.com/5677/beginning-arc-in-ios-5-part-1

Property attributes的更多相关文章

  1. @property语句

    @property声明的形式是: @property ( attributes ) type name; type和name的含义一目了然,attributes描述了如何编写访问器. 一.assign ...

  2. Unity属性(Attributes)

    Unity3d中的属性(Attributes) Attributes属性属于U3D的RunTimeClass,所以加上以下的命名空间是必须的了. using UnityEngine; using Sy ...

  3. QML Object Attributes QML对象属性

    QML Object Attributes Every QML object type has a defined set of attributes. Each instance of an obj ...

  4. iOS @property语句

    @property声明的形式是: @property ( attributes ) type name; type和name的含义一目了然,attributes描述了如何编写访问器. 一.assign ...

  5. iOS runtime探究(三): 从runtime開始理解OC的属性property

    你要知道的runtime都在这里 转载请注明出处 http://blog.csdn.net/u014205968/article/details/67639303 本文主要解说runtime相关知识, ...

  6. [翻译]NUnit---Property and Random Attributes(十四)

    小记:由于工作琐碎,没得心情翻译而且也在看<CLR vis C#>,所以断更了差不多5个月,现在继续翻译,保证会翻译完成,不会虎头蛇尾. 另:NUnit已经更新到2.6.3版本,虽然正在开 ...

  7. [翻译] Writing Property Editors 编写属性编辑器

    Writing Property Editors 编写属性编辑器   When you select a component in the designer its properties are di ...

  8. 分析Runtime的属性Property

    一.介绍 在OC中我们可以给任意的一个类以@property的格式声明属性,当然对于这个属性也会采用某一些属性关键字进行修饰,那么属性的真正的面目是啥样子的呢?其实,runtime源码中可以看到,pr ...

  9. iOS编码规范

      The official raywenderlich.com Objective-C style guide.   This style guide outlines the coding con ...

随机推荐

  1. js 变量大小写

    js对变量是区分大小写的.完毕.

  2. Javascript 四种输出方式

    JavaScript 输出 javascript 没有任何打印或输出的函数 可以通过不同的方式输出数据 使用window.alert() 弹出警告框 使用document.write()方法将内容写到 ...

  3. Windows服务安装、卸载、启动和关闭的管理器

    最近在重构公司的系统,把一些需要独立执行.并不需要人为关注的组件转换为Windows服务,Windows服务在使用的过程中有很多好处,相信这一点,就不用我多说了.但是每次都要建立Windows服务项目 ...

  4. Linux netstat

    一.简介   二.语法   三.实例 1)查看TCP连接数 netstat -n | awk '/^tcp/ {++S[$NF]} END {for (a in S) print a, S[a]}'

  5. Informatica_(3)组件

    一.Informatica介绍Informatica PowerCenter 是Informatica公司开发的世界级的企业数据集成平台,也是业界领先的ETL工具.Informatica PowerC ...

  6. PYthon end

    关键字end可以用于将结果输出到同一行,或者在输出的末尾添加不同的字符. # -*- coding:utf-8 -*- count = 1 while count <=5: i=1 while ...

  7. Java界面编程—事件的种类

    Java处理事件相应的类和监听接口大多位于 awt 包中. 在 java.swing.event 包中有专门用于 swing 组件的事件类和监听接口. awt 事件类继承自 AWTEvent,其超类是 ...

  8. How To Configure SAMBA Server And Transfer Files Between Linux & Windows

    If you are reading this article it means you have a network at home or office with Windows and Linux ...

  9. [FreeMind] 绘制思维时遇到的常见问题解决办法

    如何改变节点的摆放方向? 如果是新建节点,选择要放置节点的那一侧,按enter键,或者鼠标右键,插入平行节点即可. 如果是已经建好的节点,可以用ctrl+x, ctrl+v粘贴到另一边,或者选中子节点 ...

  10. Internet

    0x01 URL的解析/反解析/连接 解析 urlparse()--分解URL # -*- coding: UTF-8 -*- from urlparse import urlparse url = ...