我收到错误消息“无法识别的选择器发送到实例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;
}
);
};
};
}
我相信这条线
NSArray *eventsJSONData = [self.events eventsJSONData];
应该更改为该名称(或类似名称)
NSArray *eventsJSONData = [self.events eventsJSONData][@"result"];
从您的JSON对象看来,它会self.events
返回带有一个键@“ result”的字典。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句