我收到错误“无法识别的选择器发送到实例0xca51f70”应用程序崩溃在该行“ daysWeather = eventsJSONData [indexPath.row];“我读了几个关于这个问题的帖子,并了解这是一个NSArray / NSDictionary设置错误。我似乎无法弄清楚我需要改变的是什么。让我知道是否我可以发布任何其他代码。感谢您的帮助。
相关代码如下:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if(!self.events)
return 0;
NSArray *eventsJSONData = [self.events eventsJSONData];
return [eventsJSONData count];
NSLog( @"the count is %lu", (long)[eventsJSONData count]);
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"EventCell";
TDCell *cell = (TDCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier ];
if(cell == nil)
{
cell = [[TDCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"EventCell"];
}
NSDictionary *daysWeather = nil;
NSArray *eventsJSONData = [self.events eventsJSONData];
daysWeather = eventsJSONData[indexPath.row];
[cell configCell:daysWeather];
return cell;
}
json对象在调试区域中显示如下代码:
2014-09-12 03:19:45.660 iCLUB[24624:60b] JSON OWNER: {
data = {
events = {
result = (
{
"end_time" = "4:00AM";
"event_date" = "09-12-2014";
"event_id" = 84;
"event_image" = "http://www.asadfdfs.com/iclub/images/event_flyers/event114105121486dd4697f899124d1c3519c0f2272710f.png";
"event_price" = 20;
"event_tickets_total" = 200;
"event_title" = "New Test Event";
"start_time" = "1:00AM";
"venue_name" = "the box";
weekday = Friday;
}
);
};
};
}
答案 0 :(得分:0)
我相信这一行
NSArray *eventsJSONData = [self.events eventsJSONData];
应该更改为(或类似的)
NSArray *eventsJSONData = [self.events eventsJSONData][@"result"];
从你的JSON对象看来,self.events
返回一个带有一个键@“result”的字典。