【问题标题】:app crashes with error message sent to deallocated instance应用程序崩溃,错误消息发送到解除分配的实例
【发布时间】:2013-07-31 19:25:14
【问题描述】:

在我的 UIViewController 中,我添加了一个包含 uitableview 的子视图。

MSEmployeeServiceController *empServices = [[MSEmployeeServiceController alloc]initWithNibName:@"MSEmployeeServiceController" bundle:nil];
[self.totScroll addSubview:empServices.view];

MSEmployeeServiceController 类包含一个UITableView。当我尝试添加视图应用程序时崩溃并出现以下错误:

-[MSEmployeeServiceController numberOfSectionsInTableView:]: message sent to deallocated instance 0x8684030

我已经在视图中设置了数据源和委托连接。 请帮帮我。

【问题讨论】:

  • 什么时候释放empServices对象?
  • 发布更多代码以提供帮助

标签: iphone ios uitableview uiviewcontroller datasource


【解决方案1】:

如果您使用的是 ARC,请在您的 头文件

中将 MSEmployeeServiceController 的对象设为这样的属性
@property (strong, nonatomic)  MSEmployeeServiceController *empServices;

然后在你的实现文件中,

_empServices = [[MSEmployeeServiceController alloc]initWithNibName:@"MSEmployeeServiceController" bundle:nil];

[self.totScroll addSubview:empServices.view];

【讨论】:

  • 很高兴!!快乐编码..:)
猜你喜欢
  • 2015-05-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-11
  • 2013-06-04
  • 2012-04-15
相关资源
最近更新 更多