An electric plane last night, interview yourself. Have you ever asked me if I used afnetworking?
This thing, to say the truth, I do not use too much, unless a situation, that is, I apply the three-way, use other people write, just use ... In general I was sealed by myself, with my own ... So, I didn't answer it at first.
Let's just say, I'm blocking my own. Network Request class
//// netwrokhandler.h// encapsulate Network request/ Created by the call of the SaaS Generation on 14-6-27.// Copyright (c) 2014 year The call of the SaaS generation. all rights reserved.//#import <Foundation/Foundation.h>typedef void (^block) (Id result); // defines a BLOCK object @interface netwrokhandler : nsobject// block properties to be decorated with copy @property (nonatomic, copy) BLOCK passValue;+ (void) Connectnetgetdatawithurlstring: (nsstring *) Urlstr completion: (BLOCK) block;// Let the view controller in Pass in Parameters temporarily define a block block- (void) getdatawithurlstring: (nsstring *) Urlstr comlietion: (BLOCK) Block; @end
NetWrokHandler.m// Package Network Request//// created by The call of the SaaS generation on 14-6-27.// copyright (c) 2014 SaaS generation call. all rights reserved.//#import "NetWrokHandler.h" @implementation NetWrokHandler- (void) getdatawithurlstring: (nsstring *) Urlstr comlietion: (BLOCK) block{ self.passvalue = block; // Conversion Format utf8 nsstring *str = [ urlstr stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]; NSURL *url = [NSURL URLWithString:str]; nsmutableurlrequest *request = [nsmutableurlrequest requestwithurl:url cachepolicy:0 timeoutinterval:30.0f]; [request sethttpmethod:@ "GET"]; // Asynchronous request [nsurlconnection sendasynchronousrequest:request queue:[ nsoperationqueue mainqueue] completionhandler:^ (Nsurlresponse *response, nsdata *data , nserror *connectionerror) { if (nil != data) { id object = [nsjsonserialization jsonobjectwithdata:data options:nsjsonreadingmutablecontainers error:nil]; self.passvalue (Object ); } }]; }+ (void) Connectnetgetdatawithurlstring: (nsstring *) Urlstr completion: (BLOCK) block{ NetWrokHandler *network = [[NetWrokHandler alloc] init]; [network getdatawithurlstrinG:urlstr comlietion:block];} @end
It's just a simple asynchronous get request data.
Only occasional projects used in afnetworking, for example, previously done in the travel category of the app using three-party paimageview when used once ... In fact, I feel it, need to use, you use.
afnetworking as an extension of the Apple sample code in a dead LBS project.
Afnetworking is generally used as a URL to initialize, instantiating an operations queue for subsequent multithreaded operations.
Afhttprequestoperation typically requests data for HTTP and gets parsed JSON data.
Afimagerequestoperation is used to download and process pictures. (a subclass of Afhttprequestoperation)
Afjsonrequestoperation is used to process JSON data. ( a subclass of Afhttprequestoperation)
Uiimageview+afnetworking Loading Pictures asynchronously
These are the most I touch and use the most. Though, I can handle everything with my own encapsulated network class +sdwebimage. If the eldest brother said want, we will have to use, other do not say, obedient is necessary ... Unless that day, I was the boss ...
Detailed Introduction afnetworking
Network encapsulation of questions on IOS face