proper memory handling for an NSMutableArray assigned to property?

前端 未结 3 1413
余生分开走
余生分开走 2021-01-28 04:52

I have a property declared like this:

@property (nonatomic, retain) NSMutableArray *pricingLevels;

And I assign it like this:

          


        
3条回答
  •  盖世英雄少女心
    2021-01-28 05:46

    The issue is while initializing and releasing you shouldn't use self infront of the variable

    self.pricingLevels = [[[NSMutableArray alloc] init];
    //instead it should be
    
    pricingLevels = [[[NSMutableArray alloc] init];
    

    even on releasing it should be

    [pricingLevels release];
    pricingLevels = nil;
    

提交回复
热议问题