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 ...
随机推荐
- libcurl CURLOPT_WRITEFUNCTION 回调函数多次触发导致数据错乱的问题
记录一下自己犯的错误,回调函数本身就会提供数据大小,自己算反而出了问题. size_t Get_Receive_Data(void* buffer, size_t size, size_t nmemb ...
- mogdb的一主两备
# 一.环境准备 |节点类别|主机名|IP||-|-|-||主节点|mogdb1 |192.168.3.68||备节点1|mogdb2 |192.168.3.69||备节点2|mogdb3|192.1 ...
- Linux——CentOS7无法ping通外网问题
出现问题: 当在终端中出现 ping: unknown host www.baidu.com 或 ping: www.baidu.com: 未知的名称或服务 时,该如何解决? 解决方法: 1.使用ro ...
- [Unity]关于Unity中的触摸类Input.Touch以及简单的虚拟摇杆实现
InputTouch 使用Unity开发的游戏大多是移动端游戏,而一些移动端游戏完全使用触摸操作而不是点击Button Unity使用Input.Touch来管理触摸操作 Input.TouchCou ...
- pdf中添加二维码无法扫描解决方案
正常行驶的bitmap类型的二维码格式,加载到PDF中,将会导致二维码失真,无法扫描. 矢量图可根据尺寸大小进行调节,不会出现失真模糊情况 所用依赖 <PackageReference Incl ...
- Eureka出现Connect to localhost:8761 timed out问题
原先使用application.properties spring.application.name=hello-serviceeureka.client.service-url.defauleZon ...
- random及循环
题目:使用两种方式求2-20之间偶数的和,分别使用for和while 1.使用for解法: sum=0 for i in range(2,21,2): sum+=i print ("2-20 ...
- vue真实项目结构
我明白你的需求.如果你想看一个真实企业项目使用的复杂目录结构,你可以参考以下几个例子: 根据1的介绍,一个vue项目的目录结构可以细分为以下几个部分: |- src | |- api 存放所有请求接口 ...
- 【Python】【算法】【排序】用Python实现排序的三种算法
class SortTest: def __init__(self): pass # 冒泡排序 def BubbleSort(self, value): if isinstance(value, li ...
- xxx.app 已损坏,无法打开,你应该将它移到废纸篓/打不开 xxx,因为它来自身份不明的开发者解决方法
xxx已损坏,无法打开,你应该将它移到废纸篓解决办法 打不开 xxx,因为它来自身份不明的开发者 打不开xxxx,因为 Apple 无法检查其是否包含恶意软件 在安装的时候提示加载失败! 解决: 打开 ...