IOS study Note 3

Source: Internet
Author: User
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 ");
}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.