开发者

Can I autorelease a NSOperationQueue?

I have a piece of code which will run only once in the background when the app loads. I don开发者_开发知识库't want to worry about memory management of the NSOperationQueue *, can I autorelease it?

 NSOperationQueue *queue = [[NSOperationQueue alloc] init];
 NSInvocationOperation *op = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(oneTimeTask) object:nil];
 [queue addOperation:op];
 [op release];
 [queue autorelease];

Thanks


Short answer is no, if you want it to exist till your app exits.
If you auto-release it, the queue object will be released (and so deallocated) at the next cycle of the event loop, which you probably don't want...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜