Monday, 15 June 2015

iphone - ASIHTTPRequest convert response data to NSArray -



iphone - ASIHTTPRequest convert response data to NSArray -

i using asihttprequest json response server. , want convert response nsarray. code:

nsurl *url = [nsurl urlwithstring:@"http://chirkov.net.ua/iosnettest/request.php?act=showdata&query=2;0;3;0;asc"]; asihttprequest *request = [asihttprequest requestwithurl:url]; [request startsynchronous]; nserror *error = [request error]; if (!error) { nsdata *responsedata = [[nsmutabledata alloc] initwithdata:[request responsedata]]; nsarray *array = [nskeyedunarchiver unarchiveobjectwithdata:responsedata]; nslog(@"array = %@",array); }

but got exception terminating app due uncaught exception 'nsinvalidargumentexception', reason: '*** -[nskeyedunarchiver initforreadingwithdata:]: incomprehensible archive (0xffffffef, 0xffffffbb, 0xffffffbf, 0x5b, 0x7b, 0x22, 0x69, 0x64. how can solve problem?

you getting json info have convert info using nsjsonserialization. have @ class reference.

http://developer.apple.com/library/ios/#documentation/foundation/reference/nsjsonserialization_class/reference/reference.html

also check working json

iphone ios objective-c asihttprequest nskeyedarchiver

No comments:

Post a Comment