Created
March 19, 2010 07:08
-
-
Save ddribin/337314 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSArray *)arrayForReading | |
{ | |
NSArray * array; | |
@synchronized (self) { | |
array = [[_array retain] autorelease]; | |
} | |
return array; | |
} | |
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len | |
{ | |
if (state->state == 0) { | |
NSMutableData * subStateData = [NSMutableData dataWithLength:sizeof(NSFastEnumerationState)]; | |
state->state = (unsigned long)subStateData; | |
state->extra[0] = (unsigned long)[self arrayForReading]; | |
} | |
NSMutableData * subStateData = (NSMutableData *)state->state; | |
NSArray * array = (NSArray *)state->extra[0]; | |
NSFastEnumerationState * subState = [subStateData mutableBytes]; | |
NSUInteger result = [array countByEnumeratingWithState:subState objects:stackbuf count:len]; | |
state->itemsPtr = subState->itemsPtr; | |
state->mutationsPtr = subState->mutationsPtr; | |
[subStateData self]; | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment