我收到錯誤「無法識別的選擇器發送到實例0xca51f70」該應用程序崩潰在線「 daysWeather = eventsJSONData [indexPath.row];」我在這個問題上閱讀了幾篇文章,並明白這是一個NSArray/NSDictionary設置錯誤。我似乎無法弄清楚我需要改變的是什麼。讓我知道是否有任何其他代碼可以發佈。謝謝您的幫助。ios 7無法識別的選擇器發送到實例
相關代碼如下:
- (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;
}
);
};
};
}
什麼選擇是無法識別的?你也應該得到這個錯誤。 – ullstrm 2014-09-12 11:04:50
由於未捕獲的異常'NSInvalidArgumentException'而終止應用程序,原因:' - [__ NSCFDictionary objectAtIndexedSubscript:]:無法識別的選擇器發送到實例...在底部它然後打印eventsJSONData,它是上面的json對象和indexPath的描述: {length = 2,path = 0 - 0} –
user3007683
2014-09-12 11:10:34
您的部署目標是iOS 5還是更早? – F1ank3r 2014-09-12 11:14:57