views:

34

answers:

1

Hi,

I have an NSTimer running in a shared class. + (GlobalClass *)sharedInstance;

Basically it runs once, and the second time it runs, it just killed the whole app.

This is how I'm doing the NSTimer

myTimer = [NSTimer scheduledTimerWithTimeInterval:5.0
                                             target:self
                                           selector:@selector(moveMe)
                                           userInfo:nil
                                            repeats:YES];

method moveMe is just an empty method for now. So it shouldn't be something that's happening within moveMe.

Has anyone experienced this? Please enlight.

Thanks,
Tee

+1  A: 

It looks like you're missing the colon in your selector name. The selector for NSTimer takes an NSTimer as an argument. Your code that creates the timer should look like this:

myTimer = [NSTimer scheduledTimerWithTimeInterval:5.0
                                           target:self
                                         selector:@selector(moveMe:)
                                         userInfo:nil
                                          repeats:NO];

Note the colon after moveMe. Your method should then look something like this:

- (void)moveMe:(NSTimer *)aTimer {
    // Code
}
James Huddleston