Nslog (@ "Hello, world! ");
Nsdictionary * mydic = [[nsdictionary alloc] initwithobjectsandkeys: @ "Zhang San", @ "name", @ "Li Si", @ "name", nil];
Nsuinteger COUNT = [mydic count];
Nslog (@ "Number of dictionaries: % lu", count );
Nsenumerator * myenumerator = [mydic keyenumerator];
For (nsobject * object in myenumerator ){
Nslog (@ "traversal key value: % @", object );
}
Myenumerator = [[mydic allvalues] objectenumerator];
Nsstring * value;
While (value = [myenumerator nextobject])
{
Nslog (@ "traversal value: % @", value );
}
// Find the value through the key
Nsobject * myobject = [mydic objectforkey: @ "name"];
If (myobject! = Nil ){
Nslog (@ "the value found through key is: % @", myobject );
}
Nsmutabledictionary * mydic2 = [nsmutabledictionary dictionarywithcapacity: 10];
[Mydic2 setobject: @ "Alex Hu" forkey: @ "name"];
[Mydic2 setobject: @ "1388888888" forkey: @ "mobile number"];
For (nsobject * object in [mydic2 objectenumerator]) {
Nslog (@ "traversal value: % @", object );
}
Nsset * myset = [nsset setwithobjects: @ "A", @ "B", @ "C", @ "D", [nsnumber numberwithinteger: 123], nil];
Count = [myset count];
Nslog (@ "Count = % lu", count );
Myenumerator = [myset objectenumerator];
For (nsobject * object in myenumerator ){
Nslog (@ "myenumerator value = % @", object );
If ([object isrelative to: @ "A"]) {
Nslog (@ "A found ");
}
If ([object isequal: @ "B"]) {
Nslog (@ "find B ");
}
}
Nsarray * mysetarr = [myset allobjects];
For (nsuinteger I = 0; I <[mysetarr count]; I ++ ){
Nslog (@ "% lu = >%@", I, [mysetarr objectatindex: I]);
}
If ([myset containsobject: @ "D"]) {
Nslog (@ "contains the object d in the Collection ");
}