开发者

Self managing/releasing objects reported as "Potential leak of object" under Xcode -> Product -> Analyse

The Analyse feature of Xcode 4 is really great. The only problem is it thinks that objects that you initialise that are supposed to release themselves are reported as memory leaks.. ie how do you prevent it thinking this is a memory leak?

@interf开发者_运维技巧ace BackgroundTaskThing

+ doBackgroundTask: (NSString*) something {
    BackgroundTaskThing* b = [[BackgroundTaskThing alloc] init];
    [b setSomething: something];
    [b runTask];
}

....

- (void)taskComplete {
    [self release];
}

@end


From here, section Controlling 'Static Analyzer Diagnostics':

#ifndef __clang_analyzer__
// Code not to be analyzed
#endif

(not that i encourage this, but it is one way to disable it)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜