iVar LifeTime Vs Property LifeTime in Objective-C


 @interface ViewController
 {
 NSMutableArray * GetPrices;
 }
-(void)viewWillAppear:(BOOL)animated
 {
 GetPrices=[[NSMutableArray alloc]init];
  // here I’m adding objects to the array..
 }
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 {

@try { if([获取价格计数]>0) {

       //  dealing with array values
      }

}
@catch (NSException *exception) {

     // here Im using some mail service to get crash description
 }
 }

所以我在我的邮件中收到了以下信息

堆栈跟踪:-[__NSCFString计数]:发送到实例0x157153180的无法识别的选择器

stackoverflow.com/questions/5152651/...从这个公认的答案中,我认为阵列在某个时候被释放了。

现在我的疑问是,我的阵列有没有可能被释放......(假设我的应用程序在后台运行了很长时间,我的数组会发布吗)。

崩溃的可能原因是什么?谢谢。。

ARC 将保留此数组,因此在您以编程方式执行此操作之前,它无法发布。

最新更新