`
zhiblin
  • 浏览: 56567 次
  • 性别: Icon_minigender_1
  • 来自: 厦门
社区版块
存档分类
最新评论

关于retain 、readonly、readwrite、copy、assign的详细介绍

阅读更多

iphone开发一定会遇到

@property (retain, nonatomic) IBOutlet UITextView *descText;

其中的retain 还可以填写为其他如readonly、retain、read write、copy、assign等属性。

具体代表的意思下面列出:

retain   When you’re dealing with object values. The compiler will retain the value you pass in (we’ll talk more about retaining in a minute) and release the old value when a new one comes in.

 

readonly   When you don’t want people modifying the property.You can still change the field value backing the

property, but the compiler won’t generate a setter.

 

readwrite   When you want the property to be modifiable by people. The compiler will generate a getter and a  setter for you. This is the default.

 

copy             When you want to hold onto a copy of some value instead of the value itself; for example, if you want to hold onto an array and don’t want people to be able to change its contents after they set it. This sends a copy message to the value passed in then retains that.

 

assign       When you’re dealing with basic types, like ints, floats, etc. The compiler just creates a setter with a simple myField = value statement. This is the default, but not usually what you want.

 

分享到:
评论

相关推荐

    retain和copy还有assign的区别

    retain和copy还有assign的区别

    @property中的retain,copy,assign区别

    @property中的retain,copy,assign区别

    iOS开发之详谈属性设置readwrite、readonly、retain、copy、assign、nonatomic

    具体详细介绍请看下文文字说明吧,本文介绍的非常详细。 1 . 可读性: readonly、readwrite @property(readwrite,….) valueType value; 这个属性是变量的默认属性,就是如果你 (readwrite and readonly 都没有使用...

    Ios retain assign区别

    针对iOS 对象的属性的关键字(retain/assign/readonly等)的区别。彻底解决您的疑惑。

    ios_assign,retain和copy详解

    详细讲解了ios中常用关键字的使用方法的区别,着重讲解了assign,retain,copy之间的区别

    对于Retain和Assign属性的理解

    对于Retain和Assign属性的理解

    IOS中(assign,retain,copy,weak,strong)的区别以及nonatomic的含义

    IOS中(assign,retain,copy,weak,strong)的区别以及nonatomic的含义 我们在声明@property 属性时,总是要在括号中写上assign、retain、copy、weak、strong中的一个,很多时候,我们仅仅只是按照习惯去写经常写...

    iOS 对象属性详细介绍

    retain,strong, copy,weak,assign,readonly, readwrite, unsafe_unretained 下面来分别讲讲各自的作用和区别: retain,计数器加1, (增加一个指向内存的指针) 对应release(计数器-1) setter 方法对参数进行 ...

    IOS property属性详细介绍使用注意事项

    readWrite readOnly 内存管理 strong retain copy assign weak unsafe_unretained 方法命名 getter = setter = <name> 结论 1、原子性  (1)atomic  原子性,可以理解成就是生成getter、setter...

    iOS面试题分享

    简述OC中内存管理机制。与retain配对使用的方法是dealloc还是release,为什么?需要与alloc配对使用的方法是dealloc还是...readwrite,readonly,assign,retain,copy,nonatomic 、atomic、strong、weak属性的作用

    OC中的@property属性问题

    Retain,copy,assign...

    Retain.pdf

    SAS-The RETAIN Statement; Retain的用法,英文版。

    Fast copy(快速拷贝)

    FastCopy ver2.08 2011/02/28 SHIROUZU Hiroaki FastCopy is the Fastest Copy/Delete Software on Windows. It can copy/delete unicode and over MAX_PATH(260byte) pathname files. It always run by ...

    iOS常见的几个修饰词深入讲解

    主要给大家介绍了关于iOS常见的几个修饰词的相关资料,iOS修饰词包括assign、weak、strong、retain、copy、nonatomic、atomic、readonly、readwrite,文中通过示例代码介绍的非常详细,需要的朋友可以参考下

    浅析iOS中的浅拷贝和深拷贝(copy和mutableCopy)

    ios提供了copy和mutablecopy方法,顾名思义,copy...retain属性表示两个对象地址相同(建立一个指针,指针拷贝),内容当然相同,这个对象的retain值+1也就是说,retain 是指针拷贝,copy 是内容拷贝。 当然在iOS中并

    ios内存管理之深浅拷贝

    通过对不同类型的对象进行retain和copy进行深浅拷贝详细测试分析

    iOS 面试题

    3. 请问 property 的 作用,assign,copy,retain 的 区别; assign就是基本赋值 copy是重新创建一个oc对象,计数器是1 retain是对计数器+1 4.请写出实现多线程操作涉及的类及 简单 示例; NSThread, ...

    retain-keras:RETAIN递归神经网络在Keras中的重新实现

    RETAIN-Keras:重新实现RETAIN的Keras ,它允许创建高度可解释的递归神经网络模型以进行患者诊断,而不会降低模型性能 该存储库保留了Keras对RETAIN的重新实现,可以灵活地修改原始代码,引入了多个新功能,并提高...

Global site tag (gtag.js) - Google Analytics