iVar LifeTime Vs Property LifeTime in Objective-C

64 Views Asked by At
 @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..

1

There are 1 best solutions below

8
gvuksic On

ARC will retain this array, so there is no way it becomes released until you do it programatically.