[NSThread detachNewThreadSelector: @selector (fetchdata) toTarget: self withObject: nil];
URL моего фида, который возвращается как:JSON_CATEGORY_DATA_URL_STRING
Я не могу получить хороший
[
{
"group":"For Sale",
"code":"SSSS"
},
{
"group":"For Sale",
"category":"Wanted",
"code":"SWNT"
}
]
(или жеNSDictionary
) из следующего кода:NSArray
Я прочитал много сообщений на эту тему, но не получаю.
+ (NSDictionary *)downloadJSON
{
NSDictionary *json_string;
NSString *dataURL = [NSString stringWithFormat:@"%@", JSON_CATEGORY_DATA_URL_STRING];
NSLog(@"%@",dataURL);
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:dataURL]];
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
json_string = [[[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding]autorelease];
NSDictionary *json_dict = (NSDictionary *)json_string;
NSLog(@"json_dict\n%@",json_dict);
NSLog(@"json_string\n%@",json_string);
return json_string;
}
РЕДАКТИРОВАТЬ: я использую SBJSON