I found this answer:
stack overflow
What is a for in loop.
NSFastEnumerationState __enumState = {0}; id __objects[MAX_STACKBUFF_SIZE]; NSUInteger __count; while ((__count = [myArray countByEnumeratingWithState:&__enumState objects:__objects count:MAX_STACKBUFF_SIZE]) > 0) { for (NSUInteger i = 0; i < __count; i++) { id obj = __objects[i]; [obj doSomething]; } }
The problem is that I found it wrong.
First of all, when you turned on automatic link counting (ARC), you received an error message
Sending '__strong id *' to parameter of type '__unsafe_unretained_id*' changes retain/release properties of pointer

But even when I turn off ARC, I found that the array of __ objects seems weird:

This is the actual code (I assumed MAX_STACKBUFF_SIZE is 40):
@autoreleasepool { NSArray *myArray = @[@"a", @"b", @"c", @"d", @"e", @"f", @"g"]; int MAX_STACKBUFF_SIZE = 40; NSFastEnumerationState __enumState = {0}; id __objects[MAX_STACKBUFF_SIZE]; NSUInteger __count; while ((__count = [myArray countByEnumeratingWithState:&__enumState objects:__objects count:MAX_STACKBUFF_SIZE]) > 0) { for (NSUInteger i = 0; i < __count; i++) { id obj = __objects[i]; __enumState.itemsPtr NSLog(@" Object from __objects ! %@", obj);
I got EXC_BAD_ACESS when I try to get the contents of an array of __ objects. I also found out that when you try to iterate through __enumState.itemsPtr, it really works.
Could you explain to me what is going on here? Why __objects my __objects seem "crumpled". And why does it not contain the desired object? And why this error when turning on ARC.
Thank you very well in advance for your time and efforts! (I presented a screenshot to better understand what causes the error)