我有以下代码(在非 ARC 项目中):
- (void)loadWithCompleteBlock:(void (^)(void))complete
{
...
complete = [complete copy];
...
[[NSOperationQueue mainQueue] addObserver:self forKeyPath:@"operationCount" options:0 context:complete];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *) context
{
void (^complete)(void) = context;
[self performSelectorInBackground:@selector(loadFilesWithCompleteBlock:) withObject:complete];
[complete release];
}
静态分析器给出警告Potential leak of an object stored into 'complete'
我厌倦了添加NS_RELEASES_ARGUMENT
或参数,但没有任何效果。CF_RELEASES_ARGUMENT
context
有任何想法吗?