温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

NSDictionary

发布时间:2020-07-24 07:58:37 来源:网络 阅读:212 作者:NetworkAD 栏目:开发技术

//官网原文:

The NSDictionary class declares the programmatic interface to objects that manage immutable associations of keys and values. Use this class or its subclass NSMutableDictionary when you need a convenient and efficient way to retrieve data associated with an arbitrary key. NSDictionary creates static dictionaries, andNSMutableDictionary creates dynamic dictionaries. (For convenience, the term dictionary refers to any instance of one of these classes without specifying its exact class membership.)

A key-value pair within a dictionary is called an entry. Each entry consists of one object that represents the key and a second object that is that key’s value. Within a dictionary, the keys are unique. That is, no two keys in a single dictionary are equal (as determined by isEqual:). In general, a key can be any object (provided that it conforms to the NSCopying protocol—see below), but note that when using key-value coding the key must be a string (see Key-Value Coding Fundamentals). Neither a key nor a value can be nil; if you need to represent a null value in a dictionary, you should use NSNull.

翻译:

使用NSDictionary用产生的对象是用来管理不变的键值对,使用它或者它的子类NSMutableDictionary 可以很方便的使用key来查找到它所对应的value,使用NSDictionary 创建静态的(一经创建内容不可变)的字典, 而使用NSMutableDictionary创建动态的字典(内容可更改);

一个键值对在字典中被称为一个表项,每一个表项都有一个键和一个与该键对应的值,在字典中,所有的键都是唯一的,也就是说在一个字典中不存在两个相同的键,通常,一个键可以是任何OC中得对象,但是注意在使用key-value进行编码时,键必须是一个字符串,在字典中,键和值不能为nil,若需要将value置为nil,应写成NSNUll(mark:因为在对每个字典进行初始化时都是以nil作为结束);

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI