objective c - NSFastEnumeration crashing on C array with ARC -
I am am starting C array of objects and set the first element:
< code> id __strong * _objs = (ID __strong *) Colok (16 Akarf (* _ objs)); _objs [0] = @ 1; _count ++;Then I am using the following implementation NSFastEnumeration:
- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState *) state objects: (id __unsafe_unretained * ) StackBuff count: (NSUntiger) lane {NSUntiger size = _count; NSInteger calculation; State-> mutationPtr = (unsigned long *) size; Calculation = MIN (lane, size - state-> state); If (count & gt; 0) {imps selector imp = [self method: @ selector (Objektatindaks :)); Int p = state- & gt; state; Int i; For (i = 0; i & lt; count; i ++, p ++) {Stakbuf [i] = (* IMP) (self, @ selector (Objektatindaks :), P); } State-> State + = calculation; } And {count = 0; } State-> Item Ptr = stackbuf; Calculation of return; }
Unfortunately, when I run it, it crashes with EXC_BAD_ACCESS:
for (array in id object) {/ / EXC_BAD_ACCESS NSLog (@ "% @"
"post-text" itemprop = "text">
The problem is that
mutation pt which indicates memory address 1 which you are not allowed to access (and which is not even 4 bytes):
state-> mutationPtr = ( Unsigned long *) size;
this Sector replace it with a valid pointer to the beginning (Warning: below in any case can not be any sense in your situation, but at least it fixes EXC_BAD_ACCESS):
State-> mutationPtr = (unsigned long *) and _count;
Comments
Post a Comment