Skip to content

Instantly share code, notes, and snippets.

@Kentzo
Created July 5, 2011 06:19
Show Gist options
  • Select an option

  • Save Kentzo/1064337 to your computer and use it in GitHub Desktop.

Select an option

Save Kentzo/1064337 to your computer and use it in GitHub Desktop.
NSMutableArray isn't thread safe anymore
NSMutableArray *resources = [NSMutableArray new];
[otherObjects enumerateObjectsWithOptions:NSEnumerationConcurrent
usingBlock:^(id obj, NSUInteger idx, BOOL *stop)
{
id resource = [obj hardToCalcResource];
@synchronized(resources) {
[resources addObject:resource]; // Resources may be corrupted
}
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment