Property attributes
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 theNSCopyingprotocol,
you almost always should specifycopyin
your@propertydeclaration.
- retain: is
required when the attribute is a pointer to an object. The setter generated by@synthesizewill
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
strongexcept
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 tocopy.
When calling the getter of anassignproperty,
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的更多相关文章
- @property语句
@property声明的形式是: @property ( attributes ) type name; type和name的含义一目了然,attributes描述了如何编写访问器. 一.assign ...
- Unity属性(Attributes)
Unity3d中的属性(Attributes) Attributes属性属于U3D的RunTimeClass,所以加上以下的命名空间是必须的了. using UnityEngine; using Sy ...
- QML Object Attributes QML对象属性
QML Object Attributes Every QML object type has a defined set of attributes. Each instance of an obj ...
- iOS @property语句
@property声明的形式是: @property ( attributes ) type name; type和name的含义一目了然,attributes描述了如何编写访问器. 一.assign ...
- iOS runtime探究(三): 从runtime開始理解OC的属性property
你要知道的runtime都在这里 转载请注明出处 http://blog.csdn.net/u014205968/article/details/67639303 本文主要解说runtime相关知识, ...
- [翻译]NUnit---Property and Random Attributes(十四)
小记:由于工作琐碎,没得心情翻译而且也在看<CLR vis C#>,所以断更了差不多5个月,现在继续翻译,保证会翻译完成,不会虎头蛇尾. 另:NUnit已经更新到2.6.3版本,虽然正在开 ...
- [翻译] Writing Property Editors 编写属性编辑器
Writing Property Editors 编写属性编辑器 When you select a component in the designer its properties are di ...
- 分析Runtime的属性Property
一.介绍 在OC中我们可以给任意的一个类以@property的格式声明属性,当然对于这个属性也会采用某一些属性关键字进行修饰,那么属性的真正的面目是啥样子的呢?其实,runtime源码中可以看到,pr ...
- iOS编码规范
The official raywenderlich.com Objective-C style guide. This style guide outlines the coding con ...
随机推荐
- vue slot插槽的使用方法
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 团队合作之项目NABCD
小组组长 :毛松林 组员 :张浩,谢诗语 N 我们小组要开发的项目是“高校自习室查询APP”,作为一个大学生,自学是一件很重要的能力,大学的老师不可能还像高中的老师那样整天逼着你学习,爱学不学,不学 ...
- BZOJ1088或洛谷2327 [SCOI2005]扫雷
BZOJ原题链接 洛谷原题链接 很容易发现答案就只有\(0,1,2\)三种答案,而且只要知道第一个格子是否有雷就可以直接顺推下去了. 所以我们跑一次首位有雷,跑一次首位无雷判断是否可行即可. #inc ...
- Codeforces 787D. Legacy 线段树建模+最短路
D. Legacy time limit per test:2 seconds memory limit per test:256 megabytes input:standard input out ...
- 看懂 Fiddler 的瀑布图
最近准备给组内的新同学们分享下 Fiddler 这枚神器,可以讲的地方太多,我打算把一节课讲不完的内容写在博客上,大家可以随便看看.今天先介绍下 Fiddler 的瀑布图. 每个网络请求都会经历域名解 ...
- linux学习第三天 (Linux就该这么学)
今天是学习的第三天,讲了很多命令,又赶上双11,网络经常波动,我经常掉线,没有听到多少,回头再看一下录播.我也写一下讲的命令吧,也加深一下命令的印象.第三章老师讲完了. ifconfig命令:输出信息 ...
- [Robot Framework] Robot Framework怎么调试?
Robot Framework怎么debug? 在eclipse里面安装一个插件,就可以debug robot framework的project. 插件下载地址: https://github.co ...
- openssl pem密钥文件rsa加密解密例子
准备工作 命令行加密解密,用与比对代码中的算法和命令行的算法是否一致 C:\openssl_test>openssl rsautl -encrypt -in data.txt -inkey pu ...
- maven 介绍(zz )
Maven 编辑 目录 1简介 2特点 3常用命令 4推荐书籍 5Win7配置 6生命周期 1 1简介 Maven是基于项目对象模型(POM),可以通过一小段描述信息来管理项目的构 ...
- js 实现获取当前日期/时间/星期
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...