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
get, please. That is reserved for a very special purpose.getis typically used when the caller must provide their own buffer. For example,NSStringhas a methodgetCharacters:range:where the caller must provide a buffer. Similarly,NSArrayhas a method calledgetObjects:range:. Another example,NSStreamhas a class methodgetStreamsToHost:port:inputStream:outputStream:where the method returns two streams via "output" parameters.