[__NSArrayI objectAtIndex:]:发送到解除分配的实例0x7fbdae1a2080的消息

时间:2015-09-20 22:46:07

标签: ios objective-c xcode6

tableView我有几个对象显示得很好。但是,当我与列表交互并向下滚动(向前)时,应用程序将崩溃。我以前从未见过这个,也不知道为什么会这样。我正在使用第三方日历和我的代码,我想我应该提一下,但我不认为这是主要问题。

#import "VRGViewController.h"


@interface VRGViewController ()

@end

@implementation VRGViewController{
    NSArray *calendarTableData;
}

- (void)viewDidLoad
{
  [super viewDidLoad];
  // Do any additional setup after loading the view, typically from a nib.

  VRGCalendarView *calendar = [[VRGCalendarView alloc] init];
  calendar.delegate=self;
  calendar.center = self.view.center;
  [self.view addSubview:calendar];

  calendarTableData = [NSArray arrayWithObjects:@"Egg Benedict", @"Mushroom Risotto",nil];

}



-(void)calendarView:(VRGCalendarView *)calendarView switchedToMonth:(int)month targetHeight:(float)targetHeight animated:(BOOL)animated {
if (month==[[NSDate date] month]) {
    NSArray *dates = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:5], nil];
    [calendarView markDates:dates];
}
}

-(void)calendarView:(VRGCalendarView *)calendarView dateSelected:(NSDate *)date {
NSLog(@"Selected date = %@",date);
}


#pragma mark - User Defined Methods

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 
return [calendarTableData count];
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *simpleTableIdentifier = @"Services";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [calendarTableData objectAtIndex:indexPath.row];

return cell;
}


@end

Debugging with Zombies in Instruments

2 个答案:

答案 0 :(得分:1)

您必须按以下方式声明数据源:

calendarTableData = [[NSArray alloc]initWithObjects:@"Egg Benedict",
                                                    @"Mushroom Risotto",nil];

答案 1 :(得分:1)

问题来自我如何调用我的数组。

由于我使用的是第三方代码,因此我禁用了ARC。这导致了我如何调用我的对象数组的问题。感谢@meda帮助我提供答案 - 在我实施之后,我意识到我错了

相关问题