Local cache issues for «afnetworking picturesGet Application Bundle seed ID in IOS»Afnetworking Usage Summary (Usage +json parsing)
from:http://www.coneboy.com/?p=716
These days in the review page when the GET request to add more than 2 characters will appear badurl hint, breakpoint debugging found to be a lot of Chinese characters, so in the URL before using the first transcoding into UTF-8 can
Here, by the way, is the usual way to use afnetworking.
At the moment, I just use
#import "AFHTTPClient.h";
#import "AFHTTPRequestOperation.h"
These two classes
Initiate a request
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
NSString *urltmp = @ "http://www.coneboy.com"; NSString *URLTMP1 = [urltmp stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]; Transcode to UTF-8 otherwise error may occur Urltmp = URLTMP1; Nsurlrequest *request = [nsurlrequest requestwithurl:[nsurl urlwithstring:urltmp]; Afhttprequestoperation *operation = [[Afhttprequestoperation alloc] initwithrequest:request]; [Operation setcompletionblockwithsuccess:^ (afhttprequestoperation *operation, id responseobject) { NSLog (@ "Success:%@", operation.responsestring);NSString *requesttmp = [NSString stringWithString:operation.responseString]; NSData *resdata = [[NSData alloc] initwithdata:[requesttmp datausingencoding:nsutf8stringencoding]]; The system comes with JSON parsing Nsdictionary *resultdic = [nsjsonserialization jsonobjectwithdata:resdata options:nsjsonreadingmutableleaves Error: NIL]; } failure:^ (Afhttprequestoperation *operation, Nserror *error) { NSLog (@ "Failure:%@", error); [Svprogresshud dismisswitherror:@ "commit failed, please retry"]; }]; [Operation start]; } |
afnetworking Download Image
afnetworking download image is asynchronous and can be cached inside the cache very good does not block the main thread. Used to all said! And it's easy to use!
#import "Uiimageview+afnetworking.h"
1 |
[ImageView Setimagewithurl:[nsurl Urlwithstring:url]; |
Afnetworking Usage Summary (Usage +json parsing)