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. Excel上传找到错误数据类型

    一:查询数据库表中字段的类型语句 SELECT CASE WHEN col.colorder = 1 THEN obj.name ELSE '' END AS 表名, col.colorder AS ...

  2. 让 div中的div垂直居中的方法!!同样是抄袭来的(*^__^*)

    同样 ,水平居中很简单,给子div设置margin:0px auto; 垂直居中也不难::给父div设置display:table-cell;vertical-align:middle; 重点是dis ...

  3. 5.Mysql常用函数

    5.常用函数函数可以进行字符串的处理.数值计算和日期计算等,mysql可以用在SQL(DML)中以增加SQL的功能.5.1 数值函数1. abs(x) 返回x的绝对值select abs(5),abs ...

  4. 2.Mysql SQL基础

    2.Mysql SQL基础2.1 SQL简介 SQL(Structure Query Language)是结构化查询语言.2.2 SQL使用入门 2.2.1 SQL分类 SQL分为DDL.DML(DQ ...

  5. Oracle存储过程in、out、in out 模式参数

    Oracle存储过程in.out.in out 模式参数 标签: oracle存储inout参数 2016-11-14 11:59 3272人阅读 评论(0) 收藏 举报  分类: oracle(7) ...

  6. __PRETTY_FUNCTION__, __FUNCTION__, __func__

    __PRETTY_FUNCTION__, __FUNCTION__, __func__这三者的区别是什么? http://stackoverflow.com/questions/4384765/wha ...

  7. Spring ApplicationContext(十)finishRefresh

    ApplicationContext(十)finishRefresh Spring 系列目录(https://www.cnblogs.com/binarylei/p/10198698.html) 经过 ...

  8. [ES]ES集群内容灾

    ES是如何实现节点容灾的? 1. ES中的index,首先会进行分片,每一个分片数据一般都会有自己的副本数据,ES分配分片的策略会保证同一个分片数据和自己的副本不会分配到同一个节点上2. 当集群中的某 ...

  9. 商业化博客平台原型制作分享-TypePad

    TypePad是商业化博客平台,提供完全付费的博客服务,通过TypePad用户可以很容易建立自己的博客,TypePad提供博客系统该有的所有功能以及多种设计风格和外观,如果用户熟悉HTML和CSS,完 ...

  10. Java SE学习【一】

    学java也学了有1个多月了,算算时间,花在上面的时间应该是超过了100个小时了,现在的进度是变量.循环.分支.数组学完了,面向对象部分正在学.记录一下我在学习期间遇到的一些困惑与感想吧! 1.一开始 ...