#在蓝懿学习iOS的日子 #day14

Source: Internet
Author: User

This morning to learn Uitabelviewcell and afternoon learning with Uitabelviewcel to display the interface of the lyrics to the client of the mobile player, and the dictionary

Creating immutable Dictionaries

nsdictionary *dic = [nsdictionary dictionarywithobjectsandkeys:@ "Zhangsan"@ "Name", @ "@",@ "age", Nil];

DIC = @{@ "name":@ "Zhangsan" @ "Age":@ "@"};

Create a mutable dictionary

nsmutabledictionary *md = [nsmutabledictionary dictionary];

[MD SetObject:@ "Lisi" forkey:@ "name"];

[MD SetObject:@ (one) forkey:@ "age"];

NSLog(@ "%@", MD);

nsmutabledictionary *china = [nsmutabledictionary dictionary];

nsmutabledictionary *hebeidic = [nsmutabledictionary dictionary];

    [hebeidic setobject: @[@ " Luan County " , @ " nan " ,@ " laoting "] forkey: @ " Tangshan "

[Hebeidic setobject:@[@ "New town " @ "Qiaodong District" @ " Qiaoxi District "] forkey:@ " Shijiazhuang "];

[China setobject: Hebeidic forkey:@ " Hebei "];

nsmutabledictionary *liaoningdic = [nsmutabledictionary dictionary];

    [liaoningdic setobject: @[@ " Dava " , @ " she " ,@ " Three Dolls "] forkey: @ " Huludao " ];

[Liaoningdic setobject:@[@ " Huanggu District ",@ " Huanggu Parent Zone "@ " Huang Divine Comedy " ] forkey:@ " Shenyang "];

[China setobject: Liaoningdic forkey:@ " Liaoning "];

nsdictionary *lndic = [China objectforkey:@ " Liaoning "];

Nsarray *shenyangarr = lndic[@ " Shenyang "];

For (NSString *s in Shenyangarr) {

NSLog (@ "%@", s);

//    }

How to traverse a dictionary

for (nsstring *key in China . AllKeys) {

NSLog(@ " province -%@", key);

nsdictionary *shengdic = China[key];

for (nsstring *shikey in shengdic. AllKeys) {

NSLog(@ " City -%@", Shikey);

nsarray *xianarr = Shengdic[shikey];

for (nsarray *xian in xianarr) {

NSLog(@ " County -%@", Xian);

}

}

}
}

#在蓝懿学习iOS的日子 #day14

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.