0

I'm not sure why this for-in loop isn't working. I'm using a slider that calls valueChanged: whenever it moves. To simplify the code I cleaned up all my stuff, but I just want to know why this doesn't work:

- (void)valueChanged:(CCControlSlider *)sender{
        for(CCControlSlider *slider in self.arrayOfSliders){
            NSLog(@"do something");
        }
}

It crashes with EXC_BAD_ACCESS. Am I doing something illegal here? Thanks

** EDIT: The issue: self.arrayOfSliders was set to (nonatomic, assign), so it wasn't being retained.

I've set my project to ARC (I'm more used to it!), problem should be solved. Thank you!

user339946
  • 5,961
  • 9
  • 52
  • 97

1 Answers1

0

What debugging have you done? Is self.arrayOfSliders a valid object that hasn't been released?

Checking that a pointer is returned isn't enough. Try turning on NSZombie to see if the object has been deallocated.

Community
  • 1
  • 1
Wain
  • 118,658
  • 15
  • 128
  • 151
  • 3
    Not really an answer, @Wain. Questions go in the Comments section. This could be couched as an answer, though; for example, you could give advice on what debugging the OP should do. – matt Apr 11 '13 at 22:46
  • I'm afraid I can't comment yet, not enough reps. But when I can, I will. Thanks – Wain Apr 11 '13 at 22:51