I have a code that looks like this:
actualColor = 0; targetColors = [NSArray arrayWithObjects:[UIColor blueColor], [UIColor purpleColor], [UIColor greenColor], [UIColor brownColor], [UIColor cyanColor], nil]; timer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(switchScreen) userInfo:nil repeats:YES];
And in the selector, I have this:
- (void) switchScreen { [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.5]; [UIView setAnimationDelegate:self]; int totalItens = [targetColors count]; NSLog(@"Total Colors: %i",totalItens); if(actualColor >= [targetColors count]) { actualColor = 0; } UIColor *targetColor = [targetColors objectAtIndex:actualColor]; if(!firstUsed) { [firstView setBackgroundColor:targetColor]; [secondView setAlpha:0.0]; [firstView setAlpha:1.0]; firstUsed = YES; } else { [firstView setBackgroundColor:targetColor]; [secondView setAlpha:1.0]; [firstView setAlpha:0.0]; firstUsed = NO; } [UIView commitAnimations]; actualColor++; }
But it looks like I can't access my array inside ActionTime! Perhaps I missed something?
objective-c iphone cocoa
baDa Jun 22 '09 at 14:52 2009-06-22 14:52
source share