IOS development network data (used by AFNetWorking), iosafnetworking

Source: Internet
Author: User

IOS development network data (used by AFNetWorking), iosafnetworking

Before using AFNetWorking, download

Official website download version 2.5: http://afnetworking.com/

Import after download

 

Then Import

#import "AFHTTPRequestOperationManager.h"

 

 

Start data parsing: Get data in JSON format

// Use third-party AFNetWorking to parse data-(void) stringWithFormat :( NSString *) url {AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager]; // network access is asynchronous, the callback is the main thread, so programmers don't have to worry about updating the UI in the main thread _ weak NewsTableViewController * newsTVC = self; [manager GET: url parameters: nil success: ^ (AFHTTPRequestOperation * operation, id responseObject) {NSDictionary * BigDic = responseObject; // responseObject is equivalent to data NSMut AbleDictionary * dic = [BigDic objectForKey: @ "result"]; if (dic. count! = 0) {NSMutableArray * array = [dic objectForKey: @ "data"]; self. modleArray = [NSMutableArray array]; for (NSMutableDictionary * smallDic in array) {NewsModle * newmodle = [[NewsModle alloc] init]; [newmodle Syntax: smallDic]; [newsTVC. modleArray addObject: newmodle];} [newsTVC. tableView reloadData] ;}} failure: ^ (AFHTTPRequestOperation * operation, NSError * error) {}];}

 

 

 



Related Article

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.