简体   繁体   中英

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
 }

 }

So I got following info to my mail

Stack Trace: -[__NSCFString count]: unrecognized selector sent to instance 0x157153180

stackoverflow.com/questions/5152651/… from this accepted answer Im thinking that array was released at some point.

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将保留此阵列,因此除非您以编程方式进行操作,否则它不会被释放。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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