为什么NSMutableArray在init类的allo init autorelease时总是出错?

use*_*951 0 iphone xcode nsmutablearray

在某处.我放了

@property (nonatomic, retain) NSMutableArray * BusinessQueue;

-(BNUtilitiesQuick *) init {
        if (!(self = [super init]))
        {
            return nil;
        }//if the superclass is NSObject, this must be init
        self.locationManager = [[[CLLocationManager alloc] init]autorelease];
        BusinessQueue = [[[NSMutableArray alloc]init]autorelease]; 
        return self; //and return the object itself
    }
Run Code Online (Sandbox Code Playgroud)

我看到它的方式BusinessQueue = [[[NSMutableArray alloc]init]autorelease]; 将引用计数为1.1.-1表示自动释放(有时是后者)和1表示因为BusinessQueue是一个保留属性.

但是,BusinessQueue有时会被解除分配.

为什么BusinessQueue总是出错而位置经理却没有

任何错误的代码?或NSMutableArray无法在init类声明?

Hot*_*cks 5

BusinessQueue不是财产. self.BusinessQueue可能是,如果你这样定义的话.

添加:

最好/最简单的初始化方法是:

self.businessQueue = [NSMutableArray array];
Run Code Online (Sandbox Code Playgroud)