复习一下property
在面向对象程序里,一个对象不要直接访问另一个对象内部的数据。所以我们使用accessor methods来进行对象内部的数据交互。
accessor methods(getters and setters) are used as an abstraction for interacting with the object’s underlying data.
retain就是MRC版的strong
The retain attribute is the Manual Retain Release version of strong, and it has the exact same effect: claiming ownership of assigned values. You shouldn’t use this in an Automatic Reference Counted environment.
那么assign就是iOS5版本前的weak
The assign Attribute
The assign attribute doesn’t perform any kind of memory-management call when assigning a new value to the property. This is the default behavior for primitive data types, and it used to be a way to implement weak references before iOS 5
This relinquishes ownership of the object immediately after creating it, but keeps it in memory long enough for the caller to interact with it. Specifically, it waits until the end of the nearest @autoreleasepool{}block, after which it calls a normal release method. This is why there’s always an @autoreleasepool{} surrounding the entire main() function—it makes sure all of the autoreleased objects are destroyed after the program is done executing.
Setter methods can have additional side-effects. They may trigger KVC notifications, or perform further tasks if you write your own custom methods.
weak property自动设置为nil,如果指向的对象dealloc.
To avoid a dangerous dangling pointer to the memory originally occupied by the now deallocated object, a weak reference is automatically set to nil when its object is deallocated.
复习一下property的更多相关文章
- Objective-C-类(static)方法、实例方法、overwrite(覆写)、属性(property)复习
先来定义一个Human父类 定义部分: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 // // Human.h // OOP // // ...
- C#复习⑥
C#复习⑥ 2016年6月19日 23:46 Main Interfaces & Delegates 接口和委托 1.接口基本语法 public interface IList : IColl ...
- C#复习⑤
C#复习⑤ 2016年6月19日 22:39 Main Inheritance 继承 1.继承的语法结构 class A { // base class int a; public A() {...} ...
- 1 weekend110的复习 + hadoop中的序列化机制 + 流量求和mr程序开发
以上是,weekend110的yarn的job提交流程源码分析的复习总结 下面呢,来讲weekend110的hadoop中的序列化机制 1363157985066 13726230503 ...
- DAY25、面向对象总复习
面向对象总复习:面向过程编程思想: 核心是 过程 二字, 过程指的是解决问题的步骤是,即先干什么再干什么. 基于该编程思想编写程序,相当于一条流水线,一种机械式的思维方式. 面向对象编程思想: 核心是 ...
- python基础复习
复习-基础 一.review-base 其他语言吗和python的对比 c vs Python c语言是python的底层实现,解释器就是由python编写的. c语言开发的程序执行效率高,开发现率低 ...
- HIBERNATE知识复习记录4-HQL和QBC
Hibernate中共提供了三种检索方式:HQL(Hibernate Query Language).QBC.QBE(Query By Example). HQL 是Hibernate Query L ...
- HIBERNATE知识复习记录3-关联关系
先上一张图,关于几种关系映射: 抄一段解释: 基本映射是对一个实体进行映射,关联映射就是处理多个实体之间的关系,将关联关系映射到数据库中,所谓的关联关系在对象模型中有一个或多个引用.关联关系分为上述七 ...
- HIBERNATE知识复习记录1-连接及常用方法
要去面试了,复习一下HIBERNATE的相关知识吧,原来边看视频边写的代码如下,已经分不清先后次序了,大致看一看吧. 先看下总的配置文件hibernate.cfg.xml: <?xml vers ...
随机推荐
- 【Spring源码分析系列】加载Bean
/** * Create a new XmlBeanFactory with the given input stream, * which must be parsable using DOM. * ...
- Trie树的分析与实现
字典树 又称单词查找树,Trie树,是一种树形结构,是一种哈希树的变种.典型应用是用于统计,排序和保存大量的字符串(但不仅限于字符串),所以经常被搜索引擎系统用于文本词频统计.它的优点是:利用字符串的 ...
- c++ istream转换为std::string
std::istreambuf_iterator<char> eos; std::string s(std::istreambuf_iterator<char>(stream) ...
- 一篇博客搞定redis基础
redis简介 redis 一款高性能key-value数据库,实际上多用作缓存队列或者消息分发(celery),但是最常常被用来做缓存. redis安装 源码安装 $ wget http://dow ...
- dhroid - ioc高级(接口,对象注入)
下面到了接口对象的注入了解冻吧,现在才是我们的重点,这才是ioc的核心思想,上面的都是android的辅助1.5 对象依赖问题 我们先来将一下对象对象依赖的重要性,很多同学可能只学了android没学 ...
- 8.29 jQuery
2018-8-29 13:22:26 jQuery : http://www.cnblogs.com/liwenzhou/p/8178806.html 都快开学了!我得在家渡劫! 今天下午去俺弟家玩去 ...
- Spring Framework框架容器核心源码逐步剖析
目录 构建Spring环境 Spring 版本 5.1.3.RELEASE 测试类 Spring 配置文件 测试方法Main 快速进入Debug查看IOC容器构建源码 Spring IOC源码步骤分析 ...
- openstack 部署(Q版)-----Mysql、MQ、Memcached安装配置
一.安装mysql yum install -y mariadb mariadb-server python2-PyMySQL 配置my.cnf文件 vim /etc/my.cnf [mysqld] ...
- 线性DP总结(LIS,LCS,LCIS,最长子段和)
做了一段时间的线性dp的题目是时候做一个总结 线性动态规划无非就是在一个数组上搞嘛, 首先看一个最简单的问题: 一,最长字段和 下面为状态转移方程 for(int i=2;i<=n;i++) { ...
- Django ---- 基础题
一. 1.写出你所知道Djang有关的所有命令(下载.安装等) .安装django pip install django == .创建项目 diangoadmin startproject 项目名 ...