In this era of cyber-rampage ...
There is no feeling of fiction, haha??。
Well, I've written about network parsing of XML before, but now app development is rarely useful for XML parsing, and the mainstream is JSON. (I will summarize it when I have time) The three parties are more convenient for JSON parsing, because the code is too simple, please be prepared psychologically. Don't be scared.
////VIEWCONTROLLER.M//Cx-json Parsing (tripartite Jsonkit-master)////Created by Ma C on 16/3/18.//copyright©2016 year Xubaoaichiyu. All rights reserved.//#import "ViewController.h"#import "JSONKit.h"@interfaceViewcontroller ()@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; NSString* URLString =@"Http://localhost/city.json"; Nsurl* URL =[Nsurl urlwithstring:urlstring]; Nsurlrequest* request = [[Nsurlrequest alloc]initwithurl:url CachePolicy:0timeOutInterval: the]; [Nsurlconnection sendasynchronousrequest:request queue:[nsoperationqueue Mainqueue] CompletionHandler:^ (Nsurlresponse * _nullable response, NSData * _nullable data, Nserror *_nullable Connectionerror) { //The point is that this line of code, understanding can be, the three-side very useful. Nsdictionary * Dict =[Data objectfromjsondata]; Nsarray* array = [Dict objectforkey:@" City"]; for(Nsdictionary * DicttwoinchArray) {NSLog (@"%@", Dicttwo); } }]; }/*part of the result 2016-03-18 19:53:11.441 Cx-json parsing (three-party jsonkit-master) [6130:389488] {city = ({"city_id" = 1; "City_name" = "\u897f\u57ce\u533a"; }, {"city_id" = 2; "City_name" = "\u671d\u9633\u533a"; }, {"city_id" = 3; "City_name" = "\u6d77\u6dc0\u533a"; }, {"city_id" = 4; "City_name" = "\u4e30\u53f0\u533a"; }, {"city_id" = 5; "City_name" = "\u77f3\u666f\u5c71\u533a"; }, {"city_id" = 6; "City_name" = "\u901a\u5dde\u533a"; }, {"city_id" = 7; "City_name" = "\u987a\u4e49\u533a"; }, {"city_id" = 8; "City_name" = "\u623f\u5c71\u533a"; }, {"city_id" = 9; "City_name" = "\u5927\u5174\u533a"; }, {"city_id" = 10; "City_name" = "\u660c\u5e73\u533a"; }, {"city_id" = 11; "City_name" = "\u6000\u67d4\u533a"; }, {"city_id" = 12; "City_name" = "\u5e73\u8c37\u533a"; }, {"city_id" = 13; "City_name" = "\u95e8\u5934\u6c9f\u533a"; }, {"city_id" = 14; "City_name" = "\U5BC6\U4E91\U53BF"; }, */@end
An analysis of the IOS network-(the three-party jsonkit of the seven JSON parsing)