在将 Objective-C 代码迁移到 ARC 时,我无法实现 NSFastEnumeration 协议。有人可以告诉我,如何摆脱以下警告(见代码片段)?提前致谢。
// I changed it due to ARC, was before
// - (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState*) state objects: (id*) stackbuf count: (NSUInteger) len
- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState*) state objects: (__unsafe_unretained id *) stackbuf count: (NSUInteger) len
{
...
*stackbuf = [[ZBarSymbol alloc] initWithSymbol: sym]; //Warning: Assigning retained object to unsafe_unretained variable; object will be released after assignment
...
}
- (id) initWithSymbol: (const zbar_symbol_t*) sym
{
if(self = [super init]) {
...
}
return(self);
}