OC--(5)--dictionary, set, array sort: Dictionary class, Collection class, array array ordering, dictionary, quick traversal of collection, array ordering

Source: Internet
Author: User
Tags array sort


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


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.