I want to create a NSTimer that runs for lets say 10 minutes. I then want to write a while loop aftewards delaying 10 minutes of time before the line afterwards is executed. For example.
NSTimer * countDown = [NSTimer scheduledTimerWithTimeInterval:10.0 target:self selector:@selector userInfo:nil repeats:NO];
while (countDown == stil running (hasnt reached 10 minute mark) ){
// kill 10 minutes of time
}//when 10 minutes is up
execute next line of code
Instead of a while loop, just make a new timer inside of a method called by your first timer.
PS, the time interval is in seconds - 10 mins = 600 seconds, not 10.
First
The timeInterval parameter of
scheduledTimerWithTimeInterval:
method is in seconds. If you want in minutes, don't forget to multiply by60
.Second
Why would you want to wait the countDown with a while like that? Just call the lines you want to execute 10 minutes later in the selector that
NSTimer
fires.And then