I added autostart in my iOS application (add VoIP in Required background modes) and it worked fine. Then I wanted to add NSTimer. I wrote the following in - (id) init
NSLog(@"!!!!IT'S START!!!!");
MyTimer = [NSTimer scheduledTimerWithTimeInterval:60 target:self
selector:@selector(StartMyTimer) userInfo:nil repeats:YES];
- (BOOL) StartMyTimer
{
NSLog(@"Timer is wirk");
}
When my app is autostarted I get a message "!!!!IT'S START!!!!" and no one...
If some one knows what the problem is then please help!
First, maybe you want to check your English in those log messages.
Second, by convention you should be using lowercase (camelCase) names for selectors, and for variables as well ("myTimer" rather than "MyTimer").
Third, the
BOOLreturn type does not really make sense. Nor does the method namestartMyTimer. Perhaps something liketimerFiredor might be more appropriate.Finally, you have to make sure your app is still running, otherwise the timer will not be able to call the method. Also, you have to make sure the timer is not deallocated, so make sure the class that contains it is in memory. You should maybe also keep a strong reference to the timer.