//官網原文:
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作為結束);
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。