【发布时间】:2011-11-06 14:37:29
【问题描述】:
感谢这个问题/答案Automatic Reference Counting: Error with fast enumeration 我解决了一部分让我发疯的问题。
但是,我仍然收到错误消息“Assigning 'NSDictionary *__strong ' to '__unsafe_unretained id' changes retain/release properties of pointer”。我已经阅读了 ARC 编程指南和与指针转换相关的部分,但不幸的是,我还不是一个足够好的 c 程序员。
查看带有注释的代码行。任何帮助将不胜感激。提前致谢。
- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState *)state
objects: (id __unsafe_unretained *)buffer
count: (NSUInteger)bufferSize
{
if (*enumRows = [self getPreparedRow]) {
state->itemsPtr = enumRows; // Assigning 'NSDictionnary *__strong *' to '__unsafe_unretained id*' changes retain/release properties of pointer
state->state = 0;
state->mutationsPtr = &state->extra[0]; // was state->mutationsPtr = (unsigned long *) self; before
return 1;
} else {
return 0;
}
}
在 .h 文件中使用此声明
@interface BWDB : NSObject <NSFastEnumeration> {
NSDictionary * enumRows[1];
}
【问题讨论】:
标签: objective-c ios5 automatic-ref-counting