溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

NSDictionary

發(fā)布時(shí)間:2020-07-24 07:58:37 來源:網(wǎng)絡(luò) 閱讀:212 作者:NetworkAD 欄目:開發(fā)技術(shù)

//官網(wǎng)原文:

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用產(chǎn)生的對(duì)象是用來管理不變的鍵值對(duì),使用它或者它的子類NSMutableDictionary 可以很方便的使用key來查找到它所對(duì)應(yīng)的value,使用NSDictionary 創(chuàng)建靜態(tài)的(一經(jīng)創(chuàng)建內(nèi)容不可變)的字典, 而使用NSMutableDictionary創(chuàng)建動(dòng)態(tài)的字典(內(nèi)容可更改);

一個(gè)鍵值對(duì)在字典中被稱為一個(gè)表項(xiàng),每一個(gè)表項(xiàng)都有一個(gè)鍵和一個(gè)與該鍵對(duì)應(yīng)的值,在字典中,所有的鍵都是唯一的,也就是說在一個(gè)字典中不存在兩個(gè)相同的鍵,通常,一個(gè)鍵可以是任何OC中得對(duì)象,但是注意在使用key-value進(jìn)行編碼時(shí),鍵必須是一個(gè)字符串,在字典中,鍵和值不能為nil,若需要將value置為nil,應(yīng)寫成NSNUll(mark:因?yàn)樵趯?duì)每個(gè)字典進(jìn)行初始化時(shí)都是以nil作為結(jié)束);

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI