簡體   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