Saturday, 15 March 2014

iphone - AFJSONRequestOperation with JSON encoded as NSISOLatin1StringEncoding crashing -



iphone - AFJSONRequestOperation with JSON encoded as NSISOLatin1StringEncoding crashing -

i want utilize afnetworking more afjsonrequestoperation in project allow easy async calls. tried using sample code afnetworking github page

nsurl *url = [nsurl urlwithstring:@"https://alpha-api.app.net/stream/0/posts/stream/global"]; nsurlrequest *request = [nsurlrequest requestwithurl:url]; afjsonrequestoperation *operation = [afjsonrequestoperation jsonrequestoperationwithrequest:request success:^(nsurlrequest *request, nshttpurlresponse *response, id json) { nslog(@"app.net global stream: %@", json); } failure:nil]; [operation start];

which works fine, when utilize url metoffice datapoint crashes, believe might because of encoding type of json feed beingness nsisolatin1stringencoding causes problem nsjsonserialization

the way handle is

nsstring *string = [nsstring stringwithcontentsofurl:kmetofficeallsites encoding:nsisolatin1stringencoding error:&error]; nsdata *metofficedata = [string datausingencoding:nsutf8stringencoding]; id jsonobject = [nsjsonserialization jsonobjectwithdata:metofficedata options:kniloptions error:&error]

but how handle situation afjsonrequestoperation?

thanks in advance

iphone ios objective-c json afnetworking

No comments:

Post a Comment