my problem is that i want to iterate over all items of myArray and set new values. Thats all fine, when the function is called first time, but second time it crashes when reaching the for loop. Any solution?
-(void) count {
for(Square *mySquare in myArray) {
[mySquare setX:(10 * value)];
[mySquare setY:(10 * value)];
}
NSLog(...);
[NSTimer scheduledTimerWithTimeInterval:0.033 target:self selector:@selector(count) userInfo:nil repeats:NO];
}
There’s nothing wrong with the code you’ve shown, so the problem must be elsewhere. I’d guess that it’s a memory management issue. Probably, the array is autoreleased, so the next time the method is called, the autorelease pool has been drained and you have a dangling pointer, resulting in a crash.