在使用BZForursquare将附近的场馆带入UITableView时,我现在真的陷入了困境。
BZ四方:https://github.com/baztokyo/foursquare-ios-api
我在requestDidFinishLoading委托方法中获取Requestresult。在此方法中,请求对象包含多个NSDictionary,其中一个Dictionary位于request.response中。此响应Dictionary包含一个key="venues"的条目,值为JSON对象。当我把这个值Object放入字典时,类型似乎不是dictionary,而是NSCFArray:
#pragma mark BZFoursquareRequestDelegate
- (void)requestDidFinishLoading:(BZFoursquareRequest *)request {
self.meta = request.meta;
self.notifications = request.notifications;
self.response = [request.response objectForKey:@"venues"];
self.request = nil;
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
NSLog(@"%@",[self.response objectForKey:@"name"]);
}
我认为这是因为NSLog行给了我以下错误:
-[__NSCFArray objectForKey:]:无法识别的选择器发送到实例0x1e5c90f0
现在,我完全困惑了,尝试了一些失败的尝试,试图将JSON从任何类型的odDatatype中获取到NSDictionary中。一种尝试是将值Object放入NSString并使用
[NSJSONSerialization JSONObjectWithData:[responseString dataUsingEncoding:NSUTF8StringEncoding] options:0 error:&error];
将其放入字典,但也失败了,因为它仍然是一个NSCF数组。有人能告诉我如何获得的内容吗
[request.response objectForKey:@"venues"]
到NSDictionary中,这样我就可以用这个内容填充我的UITabelview?
编辑:
以下是Dictionary请求值部分的内容。响应:
(
{
categories = (
{
icon = {
name = ".png";
prefix = "https://foursquare.com/img/categories/food/default_";
sizes = (
32,
44,
64,
88,
256
);
};
id = 4bf58dd8d48988d10b941735;
name = "Falafel Restaurant";
pluralName = "Falafel Restaurants";
primary = 1;
shortName = Falafel;
}
);
contact = {
};
hereNow = {
count = 0;
groups = (
);
};
id = 4df3489dfa76abc3d86c4585;
likes = {
count = 0;
groups = (
);
};
location = {
cc = DE;
city = "Vinn";
country = Germany;
distance = 92;
lat = "51.44985";
lng = "16.648693";
state = "Nordrhein-Westfalen";
};
name = "Yildiz DU00f6ner";
specials = (
);
stats = {
checkinsCount = 3;
tipCount = 0;
usersCount = 2;
};
verified = 0;
}
这似乎来自NSCF阵列类型。我如何从这个字典中创建另一个字典,以便按键访问JSON值?对不起,如果我今天真的很慢。。。
你要求"场地",我认为这是一个这样的数组。因此,在反序列化json之后,记录返回对象以查看您得到了什么。几乎可以肯定的是,这是一系列字典。