Nsdictionary serves the same purpose as the dictionary class in Java and provides a set of "key-value" pairs.
Summary of common nsdictionary Methods
+ (ID) dictionarywithobjectsandkeys: obj1, key1, obj2, key2, ...... Nil |
Add objects and key values in sequence to create a dictionary. Note that the end is nil. |
-(ID) initwithobjectsandkeys: obj1, key1, obj2, key2, ...... Nil |
Initialize a new dictionary, adding objects and values in sequence, ending with nil |
-(Unsigned INT) count |
Returns the number of records in the dictionary. |
-(Nsenumerator *) keynsenumerator |
Returns all keys in the dictionary to an nsenumerator object. |
-(Nsarray *) keyssortedbyvalueusingselector :( SEL) Selector |
Sort all keys in the dictionary by the method specified by selector and return the result. |
-(Nsenumerator *) objectenumerator |
Returns all values in the dictionary to an nsenumetator type object. |
-(ID) objectforkey: Key |
Returns the object with the specified key value. |
Summary of common nsmutabledictionary Methods
+ (ID) dictionarywithcapacity: Size |
Create a variable Dictionary of size |
-(ID) initwithcapacity: Size |
Initializes a variable Dictionary of size. |
-(Void) removeallobjects |
Delete all elements in the dictionary |
-(Void) removeobjectforkey: Key |
Delete the key position element in the dictionary |
-(Void) setobject: OBJ forkey: Key |
Add (Key, OBJ) to the dictionary. If the key already exists, replace it with obj. |