Analysis of iOS multi-threading and network development JSON data

Source: Internet
Author: User

Shimen the main contribution, respect the work of the author, please do not reprint.

If the article is helpful to you, you are welcome to donate to the author, support Shimen, and donate any amount. Heavy on the mind ^_^

I want to donate: Click Donate

Cocos2d-x source code Download: Dot I teleport

Games Official Download:HTTP://DWZ.CN/RWTJL

Game video preview:http://dwz.cn/RzHHd

Game Development Blog:Http://dwz.cn/RzJzI

Game Source code transfer : Http://dwz.cn/Nret1


basic use of JSON in A.ios1. Parsing JSON data(1) JSON deserializationObject
{}
Structure of the key-value pairs for format {key:value, Key:value,...}
Ability to deserialize into nsdictionary in OC
Array
[]
format ["Java", "JavaScript", "VB",...]
Ability to deserialize into Nsarray in OC

Tips
The JSON data format is similar to the high-speed packaging method in OC
JSON has the same data format to support nesting
 (2) JSON toolStart with iOS 5. Using Nsjsonserialization to parse JSON

Other three common JSON parsing third-party libraries:
Sbjson because the API is easy to use, there may be some applications that remain
The developer of Jsonkit Jsonkit said: Jsonkit performance is better than Apple
Touchjson
 (3) Serialization & deserializationDeserialization
[Nsjsonserialization jsonobjectwithdata:data options:0 error:null];

Serialization of
[nsjsonserialization Datawithjsonobject:array options:0 error:null];
 Sample:
1     //Send messages synchronously2NSData *data =[nsurlconnection sendsynchronousrequest:request returningresponse:nil Error:nil];3    4     //parsing Data5     if(data) {//Get Return Data6         //Unblock screen lock7 [Mbprogresshud Hidehud];8        9         //parsing JSON dataTenNsdictionary *dict =[nsjsonserialization jsonobjectwithdata:data options:nsjsonreadingmutableleaves Error:nil]; One         A         //processing the returned data -NSString *result = dict[@"Success"]; -         if(Result) { the [Mbprogresshud Showsuccess:result]; -}Else { -result = dict[@"Error"]; -             if(Result) { + [Mbprogresshud Showerror:result]; -             } +         } A}Else { at[Mbprogresshud ShowError:@"the Internet is busy, please try again later"]; -}

Shimen the main contribution, respect the work of the author, please do not reprint.

Suppose the article is helpful to you. Welcome to donate to the author, support Shimen, donate amount arbitrarily. Heavy on the mind ^_^

I want to donate: Click Donate

Cocos2d-x source code Download: Dot I teleport

Games Official Download:HTTP://DWZ.CN/RWTJL

Game video preview:http://dwz.cn/RzHHd

Game Development Blog:Http://dwz.cn/RzJzI

Game Source code transfer : Http://dwz.cn/Nret1

Analysis of iOS multi-threading and network development JSON data

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.