Dictionary
1. Fast enumeration Forin runtime cannot change internal data
For (< #type *object#> Inch< #collection #>) {< #statements #>}
//object//Array
For (contact *contact in friends) { [contact show]; }
Determine if empty nsstring *ns ==nil Nsinteger inte==0
A. Dictionary
A dictionary? is used to save a mapping relationship (Key-valueThe set of data. Value,key
Nsdictionary *liudehua=[[nsdictionary alloc]initwithobjectsandkeys:@ "Liudehua", @ "name", @ "Man", @" Sex ", [nsnumber numberwithint:56],@ "Age", NIL];
//PassKeyGetValue
nsstring* Sex=[liudehua Valueforkey: @ "Sex"];
Nsarray *allvalues=[liudehua Allvalues];
Two. Variable dictionaries
Nsmutabeldictionary
//Add to
SetValue:forKey:setObject:forKey:object Cannot be aNil
The first method allows aValueis a null value A second methodObject Null values are not allowed to appear
Modify
Setvalue:forkey:
If the dictionary has a correspondingKeyis to modifyValueValue
If there is no correspondence in the dictionarykey Add the corresponding key value to (Key-value);
// delete removeobjectforkey : by key delete the corresponding value Value
[Dandan removeobjectforkey:@ "Sex"];
bubble Sort//
OC--(5)--dictionary, set, array sort: Dictionary class, Collection class, array array ordering, dictionary, quick traversal of collection, array ordering