I'm working in some iPhone app thats shows many apps from the app store and I want to get their info using json.
I was able to do that for a single app, but now i'm trying to get info for all my apps that i stored their identifiers used in the JSon URL, in an NSMutableArray.
The problem that I get the info for only the first item in my array, and for the others I get this error :
Code:
-JSONValue failed. Error trace is: (
"Error Domain=org.brautaset.JSON.ErrorDomain Code=11 \"Unexpected end of string\" UserInfo=0x4b661c0 {NSLocalizedDescription=Unexpected end of string}"
I'm using those methods to get info from the app store using json :
Code:
-(void)loadDatawithCode:(NSString*)_code
{
self.responseData = [NSMutableData data];
NSString * url = [NSString stringWithFormat:@"%@%@",@"http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/wa/wsLookup?id=",_code];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[connection release];
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
self.responseData = nil;
NSArray* results = [(NSDictionary*)[responseString JSONValue] objectForKey:@"results"];
[responseString release];
tmpApp= [[App alloc]init];
// assuming you have 1 valid entry
NSDictionary *result = [results objectAtIndex:0];
tmpApp.price = [result objectForKey:@"price"];
tmpApp.name=[result objectForKey:@"trackCensoredName"];
tmpApp.icon=[result objectForKey:@"artworkUrl60"];
NSLog(@"application : %@ , Price : %@ , icon path : %@",tmpApp.name, tmpApp.price,tmpApp.icon);
}
Someone may have an idea? thanks.