이 그것을 해결됩니다에서이 선언
- (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;
}
}
.
@interface BWDB : NSObject <NSFastEnumeration> {
__unsafe_unretained NSDictionary *enumRows[1];
}
게시 한 코드에 따르면이 코드는 매번 확인하기 전에 할당해야하므로 완벽하게 안전해야합니다. 사실 인스턴스 변수를 전혀 만들 필요가 없습니다. 내가 NSDictionaries의 포인터 [] 타입의 배열을 가지고있는 많은 가치가없는 점에 유의해야한다
{
__unsafe_unretained NSDictionary *enumRows[1];
if ((*enumRows = [self getPreparedRow])) {
state->itemsPtr = NULL;
state->itemsPtr = enumRows;
state->state = 0;
state->mutationsPtr = &state->extra[0];
return 1;
} else {
return 0;
}
}
:
당신은 뭔가를 할 수 있습니다. 단순히 NSArray를 사용하여 NSDictionaries를 유지하는 것이 훨씬 더 유리할 것입니다.
'id'는 이미 포인터입니다. –