Beginning IOS 7 Development Exploring the IOS SDK - Navigation Controllers and Table Views
Note You may notice that the familyNames property is declared using the copy keyword instead of strong. What’s up with that? Why should we be copying arrays willy-nilly? The reason is the potential existence of mutable arrays.
Imagine if we had declared the property using strong, and an outside piece of code passed in an instance of NSMutableArray to set the value of the familyNames property. If that original caller later decides to change the contents of that array, the BIDRootViewController instance will end up in an inconsistent state, where the contents of familyNames is no longer in sync with what’s on the screen! Using copy eliminates that risk, since calling copy on any NSArray (including any mutable subclasses) always gives
us an immutable copy. Also, we don’t need to worry about the performance impact too much. As it turns out,
sending copy to any immutable object doesn’t actually copy the object. Instead, it returns the same object
after increasing its reference count. In effect, calling copy on an immutable object is the same as calling
retain, which is what ARC might do behind the scenes anytime you set a strong property. So, it works out
just fine for everyone, since the object can never change.
This situation applies to all value classes where the base class is immutable, but mutable subclasses exist.
These value classes include NSArray, NSDictionary, NSSet, NSString, NSData, and a few more.
Any time you want to hang onto an instance of one of these in a property, you should probably declare the
property’s storage with copy instead of strong to avoid any problems.
Beginning IOS 7 Development Exploring the IOS SDK - Navigation Controllers and Table Views的更多相关文章
- 从零开始学ios开发(十六):Navigation Controllers and Table Views(下)
终于进行到下了,这是关于Navigation Controllers和Table Views的最后一个例子,稍微复杂了一点,但也仅仅是复杂而已,难度不大,我们开始吧. 如果没有上一篇的代码,可以从这里 ...
- 从零开始学ios开发(十五):Navigation Controllers and Table Views(中)
这篇内容我们继续上一篇的例子接着做下去,为其再添加3个table view的例子,有了之前的基础,学习下面的例子会变得很简单,很多东西都是举一反三,稍稍有些不同的内容,好了,闲话少说,开始这次的学习. ...
- 从零开始学ios开发(十四):Navigation Controllers and Table Views(上)
这一篇我们将学习一个新的控件Navigation Controller,很多时候Navigation Controller是和Table View紧密结合在一起的,因此在学习Navigation Co ...
- 翻译Beginning iOS 7 Development中文版
不会iOS开发好像真的说只是去,来本中文版的Beginning iOS 7 Development吧. 看了Beginning iOS 7 Development这本书,感觉蛮不错的.全英文的,没有中 ...
- 李洪强iOS开发之-环信02_iOS SDK 介绍及导入
李洪强iOS开发之-环信02_iOS SDK 介绍及导入 iOS SDK 介绍及导入 iOS SDK 介绍 环信 SDK 为用户开发 IM 相关的应用提供的一套完善的开发框架.包括以下几个部分: SD ...
- 李洪强iOS开发之-环信01_iOS SDK 前的准备工作
李洪强iOS开发之-环信01_iOS SDK 前的准备工作 1.1_注册环信开发者账号并创建后台应用 详细步骤: 注册并创建应用 注册环信开发者账号 第 1 步:在环信官网上点击“即时通讯云”,并点 ...
- 《转》iOS 平台 Cocos2d-x 项目接入新浪微博 SDK 的坑
最近在做一个 iOS 的 cocos2d-x 项目接入新浪微博 SDK 的时候被“坑”了,最后终于顺利的解决了.发现网上也有不少人遇到一样的问题,但是能找到的数量有限的解决办法写得都不详细,很难让人理 ...
- iOS Swift WisdomScanKit图片浏览器功能SDK
iOS Swift WisdomScanKit图片浏览器功能SDK使用 一:简介 WisdomScanKit 由 Swift4.2版编写,完全兼容OC项目调用. WisdomScanKit的 ...
- iOS Swift WisdomKeyboardKing 键盘智能管家SDK
iOS Swift WisdomKeyboardKing 键盘智能管家SDK [1]前言: 今天给大家推荐个好用的开源框架:WisdomKeyboardKing,方面iOS日常开发,优点和功能请 ...
- iOS Mobile Development: Using Xcode Targets to Reuse the Code 使用xcode targets来实现代码复用
In the context of iOS mobile app development, a clone is simply an app that is based off another mob ...
随机推荐
- Mybatis-概览地图
思考: "为什么在使用 Mybatis 的时候,只需定义一个接口,不用写实现类就能使用XML中或者注解上配置好的SQL语句,就能完成对数据库 CRUD 的操作呢?" 这是因为用到了 ...
- 微信小程序分享百度网盘文件的实现思路
需求: 在小程序中点击按钮,获取百度网盘文件的下载地址. 实现思路: 1.网盘文件的下载地址,使用官方API只能自己下载,别人通过dlink无法下载,所以采用网页端生成接口. 好处是可以自定义提取码, ...
- 使用AJAX绑定点击事件将接口值返回渲染到指定位置
AJAX 是局部的刷新或者叫做无刷新技术 首先是js部分,这里注意不紧要引入express模块,还需要把cors模块也引入 在下面添加了判断,用来判断所取得的随机值是否在0.5以上 接下来是HTML部 ...
- @NotNull,@NotBlank,@NotEmpty注解的区别
开发中常看见@NotNull,@NotBlank,@NotEmpty三个注解,但却没有深入了解过,下面介绍一下他们的应用场景和区别 @NotNull:主要用在基本数据类型上(Int,Integer,D ...
- Python-网络编程和多进程多线程开发
网络编程 osi7层模型 以通过访问网站发送请求数据为例,每一层会做如下的事情 应用层:规定数据的格式. "GET /s?wd=你好 HTTP/1.1\r\nHost:www.baidu.c ...
- 前端常见的Vue面试题目汇总
请说一下响应式数据的原理 默认Vue在初始化数据时,会给data中的属性使用Object.defineProperty重新定义所有属性,当页面到对应属性时,会进行依赖收集(收集当前组件中的watche ...
- Java中Set里remove详解
例如 1 HashSet set = new HashSet(); 2 Person p1 = new Person(1001,"AA"); 3 Person p2 = new P ...
- webpack5的基本用法
webpack的基本使用 webpack 本身功能有限: 开发模式: 仅能编译JS中的ES Module 语法 生产模式: 能编译ES Module 语法, 还能压缩JS代码 添加实例文件 npm i ...
- kubernetes 集群部署问题点统计
1.安装网络插件报错 error unable to recognize "calico.yaml": no matches for kind "DaemonSet&qu ...
- 【SSO单点系列】(8):CAS4.0 之整合CMS
一.描术 CMS 是采用shiro来认证的: 过程 1.调用 login.do get方式 来打开登录页面 2.录入用户名密码后调用/login.do的post来提交 并且只能是post提交 Jar ...