Provinces and Cities (simplified version)

Source: Internet
Author: User

//

Main.m

Provinces and Cities (simplified version)

//

Created by Dllo on 16/2/27.

COPYRIGHT©2016 year Dllo. All rights reserved.

//

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {

@autoreleasepool {

NSString *filestr = [NSString stringwithcontentsoffile:@/users/dllo/desktop/c Language/C01_WORK/FOLDER/C02_ branch structure/c02_test /looping structure/C03_ loop structure/c04_ array/c04_ array/additional problem/oc/miku/c_8 function/oc_new/c_09 struct/c-10-pointer/manageofstuinfo/studenttest/class and object/Inheritance/ fraction/review/provinces (simplified version)/Provinces and Cities (simplified version)/area.txt "Encoding:nsutf8stringencoding Error:nil";

Nsarray *linearray = [filestr componentsseparatedbystring:@ "\ n"];

NSLog (@ "%@", Linearray);

Nsmutabledictionary *china = [Nsmutabledictionary dictionarywithcapacity:40];

NSString *provincename = [[NSString alloc]init];

NSString *cityname = @ "";

For (NSString *name in Linearray) {

if (![ Name hasprefix:@ ""]) {

/** added the dictionary to the China Dictionary, Key is a declaration, value is a dictionary */

Nsmutabledictionary *provincedic = [Nsmutabledictionary dictionarywithcapacity:20];

[China Setobject:provincedic Forkey:name];

/** Record the province name, for the following can be taken to the corresponding province dictionary * *

Provincename = name;

}else if (![ Name hasprefix:@ ""]) {

/**name is the city name */

/** create an array to store the name of the zone */

Nsmutablearray *array = [Nsmutablearray arraywithcapacity:30];

/** out the corresponding dictionary from China */

Nsmutabledictionary *tempdic = [China objectforkey:provincename];

/** adds a key to the array as the city name, and the value is array */

CityName = name;

[Tempdic Setobject:array Forkey:name];

}else{

/** name is the name of the zone */

/** Remove Array */

Nsmutablearray *temparray = [[China objectforkey:provincename]objectforkey:cityname];

/** Adding a zone name to the array */

[Temparray Addobject:name];

}

}

NSLog (@ "%@", China);

NSData *data = [nsjsonserialization datawithjsonobject:china options:nsjsonwritingprettyprinted Error:nil];

NSString *str = [[NSString alloc]initwithdata:data encoding:nsutf8stringencoding];

NSLog (@ "%@", str);

}

return 0;

}

Area.txt

Beijing 1
Beijing City 1
Xicheng 1
Dongcheng 2
Chongwen District 3
Xuanwu District 4
Chaoyang 5
Fengtai 6
Shijingshan District 7
Haidian District 8
Mentougou District 9
Fangshan District 10
Tongzhou District 11
Shunyi District 12
Changping District 13
Daxing District 14
Huairou 15
Pinggu District 16
Miyun District 17
Yanqing District 18
Tianjin 2
Tianjin City 2
Heping 19
Hedong District 20
Hexi District 21
Nankai District 22
Hebei District 23
Hongqiao District 24
Tanggu District 25
Hangu District 26
Grand Port District 27
Dongli District 28
Xiqing District 29
Jinnan District 30
Beichen District 31
Wuqing District 32
Baochi District 33
Ninghe County 34
Jinghai County 35
Jixian 36
Hebei 3
Shijiazhuang City 3
Changan District 37
Qiaodong District 38
Qiaoxi District 39
Xinhua District 40
Jingxing Mining Area 41
Yuhua District 42
Xinji 43
Gaocheng 44
Jinju 45
Xinle 46
Luquan 47
Jingxing County 48
Zhengding County 49
Luancheng County 50
Hangtang County 51
Lingshou County 52
Gaoyi County 53
Shenze County 54
Zanhuang County 55
Wuji County 56
Pingshan 57
Yuan \346\260\217 County 58
Zhao County 59
Tangshan 4
Lubei District 60
Lunan District 61
Guzhi District 62
Kaiping District 63
Fengnan District 64
Fengrun District 65
Zunhua 66
Qianan 67
Luan County 68
Luannan County 69
Leting 70
Qianxi County 71
Yutian County 72
Tanghai County 73
Qinhuangdao Shi 5
Haigang District 74
Shanhaiguan District 75
Beidaihe District 76
Changli County 77
Funing County 78
Lulong County 79
Qinglong County 80
Economic Development Zone 81
Hanhan 6
Congtai District 82
Hanshan District 83

Provinces and Cities (simplified version)

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.