简体   繁体   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) { @try {if([Getprices count]> 0){

       //  dealing with array values
      }


}
@catch (NSException *exception) {


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

 }

So I got following info to my mail 所以我收到了以下信息

Stack Trace: -[__NSCFString count]: unrecognized selector sent to instance 0x157153180 堆栈跟踪:-[__ NSCFString count]:无法识别的选择器已发送到实例0x157153180

stackoverflow.com/questions/5152651/… from this accepted answer Im thinking that array was released at some point. 从这个公认的答案中获得stackoverflow.com/questions/5152651/…我认为该数组在某个时候发布了。

Now my doubt is, Is there any chance of my array become released… (Let us say my app is in background for a long time, will my array gets released). 现在,我的疑问是,我的阵列是否有可能被释放……(让我们说我的应用程序长时间处于后台运行,我的阵列会被释放)。

What are possible reasons for that crash ? 崩溃的可能原因是什么? Thank You.. 谢谢..

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

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

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