ios - [__NSArrayI objectAtIndex :]: message sent to deallocated instance 0x7fbdae1a2080

标签 ios objective-c xcode6

tableView 中,我有一些对象显示得很好。但是,当我与列表交互并向下(向前)滚动时,应用程序将崩溃。我以前从未见过这种情况,也不知道为什么会这样。我将第 3 方日历与我的代码结合使用,我认为我应该提及这一点,但我认为这不是主要问题。

#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

最佳答案

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

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

关于ios - [__NSArrayI objectAtIndex :]: message sent to deallocated instance 0x7fbdae1a2080,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32685094/

相关文章:

ios - Swift:延迟加载变量与 MVC 模型?

ios - 在 iOS 应用程序中加载自定义动态库 (.dylib)

iOS/iPhone 应用程序似乎为我的文本添加了颜色 mask /颜色阴影

ios - xcode 项目中的应用程序没有改变

ios - Storyboard编辑器中的内容消失了

ios - UINavigationBar 元素太靠近 UIStatusBar

ios - 如何从图像路径获取 MIME 类型以发送到服务器

ios - 如何使用 URLSession 解析并将它们导入 Swift 中的数组中?

ios - 如何更新表格 View 单元格?

python - Objective-C 与 Python 中的 RegEx 性能