开发者

why NSMutableArray Always error when allo init autorelease at init class?

Somewhere on .h I put

@property (nonatomic, retain) NSMuta开发者_C百科bleArray * 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
    }

The way I see it BusinessQueue = [[[NSMutableArray alloc]init]autorelease]; will make reference count 1. 1 for alloc. -1 for autorelease (sometimes latter) and 1 because BusinessQueue is a retain property.

However, BusinessQueue will get deallocated sometimes usually.

Why BusinessQueue always error but location manager doesn't

any wrong code? or NSMutableArray Can't be declared at init class?


BusinessQueue is not a property. self.BusinessQueue may be, if you defined it that way.

Added:

And the best/simplest way to do the initialization is:

self.businessQueue = [NSMutableArray array];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜