2
所以我仍然在学习iOS和JSON。iOS flickr搜索照片json返回零
所以我认为我已经理解了基础知识(显然是某种东西):也许它是一个编码问题。
#define flickrGetURL [NSURL URLWithString:@"http://www.flickr.com/services/rest/?method=flickr.photos.search&tags=football&safe_search=1&per_page=20&format=json&api_key=YOURAPIREPLACESHERE"]
NSData* data = [NSData dataWithContentsOfURL:flickrGetURL];
NSError* error;
//this works
NSString *stringData = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"Response data being called : %@", stringData);
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
if(json == nil)
{
NSLog(@"NULL");
}else
NSLog(@" WORKED");
因此,URL请求看起来不错,并且String会打印出完整的JSON对象。 但是我创建的JSON对象是NILL,也许这是一个编码问题。
有没有关于编码? (在非Twitter JSON页面上,这种方法奏效)。
看起来像你有当您键入您的标题时,您的大写字母锁定键被激活,我已经将其修正为对眼睛更友好。 – Femaref