fast enumeration on a NSArray / NSMutableArray returned from block
I have the following in a success block for an AFNetworking getPath call:
+(void)allItemsWithBlock: (void (^)(NSArray *items)) block
{
...
NSMutableArray *mutableItems = [NSMutableArray array];
for (NSDictionary *attributes in [responseObject valueForKey:@"data"]) {
Item *item = [[Item alloc] initWithAttributes:attributes];
[mutableItems addObject:item];
}
NSLog(@"here is a count: %i", [mutableItems count]);
if(block){
block(mutableItems);
}
and in the block that gets passed in, I have the following but get the
error listed as a comment:
[Item allItemsWithBlock:^(NSArray *items){
for(Item *thisItem in *items){ // The type 'NSArray' is not a pointer
to a fast-enumerable object
NSLog(@"in the block here");
}
}];
I've read up on trying to fast-enumeration but am not sure what the
problem is. Is the NSMutableArray -> NSArray an issue? Is it because this
array is created in a block and thus could be seen as possibly still 'open
for change'? I have seen code like this before in our projects and doesn't
seem to be a problem.
thx for any help
No comments:
Post a Comment