繁体   English   中英

iVar生命周期与Objective-C中的属性生命周期

[英]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([Getprices count]> 0){

       //  dealing with array values
      }


}
@catch (NSException *exception) {


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

 }

所以我收到了以下信息

堆栈跟踪:-[__ NSCFString count]:无法识别的选择器已发送到实例0x157153180

从这个公认的答案中获得stackoverflow.com/questions/5152651/…我认为该数组在某个时候发布了。

现在,我的疑问是,我的阵列是否有可能被释放……(让我们说我的应用程序长时间处于后台运行,我的阵列会被释放)。

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

ARC将保留此阵列,因此除非您以编程方式进行操作,否则它不会被释放。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM