Notice: This article is just a note.
Here are some more important facts about NSDictionary:
• Whenever you add an object to a dictionary, the dictionary retains it. Whenever you remove an object from a dictionary, the dictionary releases it.
• There can only be one object for each key. Therefore, if you add an object to a dictionary and an object is already stored with that key, the new object is added to the dictionary and the previous one is removed.
• If you want to associate multiple objects with one key, you can add them to the dictionary as an array.
• An NSDictionary is useful when you want to name the entries within a collection. In other development environments, this is called a hash map or hash table
While there are many ways to hack together a unique string, Cocoa Touch has a mechanism for creating universally unique identifiers (UUIDs), also known as globally unique identifiers (GUIDs). Objects of type CFUUIDRef can represent a UUID and are generated using the time, a counter, and a hardware identifier, usually the MAC address of the ethernet card.
However, CFUUIDRef is not an Objective-C object; it is a C structure and part of the Core Foundation API. Core Foundation is a C API that is already included in the template projects and contains the building blocks for applications including strings, arrays, and dictionaries. Core Foundation “classes” are prefixed with CF and suffixed with Ref. Other examples include CFArrayRef and CFStringRef. Many objects in Core Foundation have an Objective-C counterpart, and NSString is the Objective-C version of CFStringRef. However, CFUUIDRef does not have an Objective-C counterpart and knows nothing at all about Objective-C. Thus, when it produces a UUID as a string, that string cannot be an NSString – it must be a CFStringRef.
Many Core Foundation objects can simply be typecast as their Objective-C counterpart. Here’s an example:
// Create an instance of a CFStringRef
CFStringRef someString = CFSTR("String");
// Turn it in to an NSString
NSString *coolerString = (NSString *)someString;
We call this toll-free bridging. (And it works because the structures in memory are equivalent. How smart is that?)
分享到:
相关推荐
iPhone狂:约会iPhone
iPhone开发Objective-C语法入门 iphone 入门 iphone 开发入门 iPhone开发Objective-C语法入门 iphone 入门 iphone 开发入门
Assuming only a minimal working knowledge of Objective-C, and written in a friendly, easy-to-follow style, Beginning iPhone Development offers a complete soup-to-nuts course in iPhone and iPod Touch ...
PDF格式,添加了书签,英文版。中文译名为《iPhone开发基础教程》。
iPhone开发秘籍:第2版(The iPhone Developer's Cookbook),英文版,清晰PDF版。iphone开发必备佳作,在第一版的基础上进行了全面修订和大量扩充。iPhone开发的重量级参考书,揭示官方文档未详述的细节,代码示例...
Objective-C是Mac软件开发领域最主要的开发语言。假如我们对面向对象的思维已经C语言都很熟悉的话,对于我们学习Objective-C将会非常有用。
【iphone应用开发】iphone应用开发之六:UITableView的详细讲解(一)
新手iPhone开发 ,让您学的轻松,看得放心.
【内容提要】本书深入探讨了基于iOS的游戏设计、游戏开发根据相关的各类处理方案,并对颇具技巧的难点内容进行深入讨论。... iOS游戏开发 基于iPad,iPhone和iPod Touch. 北京:清华大学出版社, 2015.05.
Beginning iPhone Development: Exploring the iPhone SDK by Dave Mark, Jeff LaMarche
iPhone开发实战 iPhone开发 iPhone iPhone4 iPhone开发实战 iPhone开发 iPhone iPhone4
Iphone开发系列源码——Iphone主题源码Iphone开发系列源码——Iphone主题源码Iphone开发系列源码——Iphone主题源码Iphone开发系列源码——Iphone主题源码Iphone开发系列源码——Iphone主题源码Iphone开发系列源码...
Beginning iPhone Development: Exploring the iPhone SDK by Dave Mark, Jeff LaMarche 一共两个压缩包
中文介绍:iPhone是一种全新的移动平台,苹果公司为它推出了强大的软件开发工具包iPhone SDK。本书是一部关于iPhone SDK和iPhone开发的基础教程,内容翔实、语言生动。书中结合消费类设备上常见的实例,循序渐进地...
iPhone 3.0: The Missing Manual (epub 格式) by David Pogue O'Reilly iPad 可用 iPhone Stanza 可用 Android aldiko 可用 By way of a printed guide to the iPhone, Apple provides only a fold-out leaflet....
这里推荐两本书《objective-c基础教程》和《iphone开发基础教程》,这两本都是圣经级的巨作,我相信每一个iphone开发人员应该都不会错过这两本书的。 等你xcode和objective-c摸熟之后,或者说,上面提到的那两...
Iphone开发系列源码——iPhone版Wordpress源代码Iphone开发系列源码——iPhone版Wordpress源代码Iphone开发系列源码——iPhone版Wordpress源代码Iphone开发系列源码——iPhone版Wordpress源代码Iphone开发系列源码...
基于doubango的iphone客户端:源代码结构简介, 我花了好长时间才做出来的,不容易啊
如何用cocos2d制作iphone游戏:更猛的怪物和更多得管卡,大家动手试试啊