• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSTimer issue, NSCalendarDate issue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTimer issue, NSCalendarDate issue


  • Subject: NSTimer issue, NSCalendarDate issue
  • From: Michael Hanna <email@hidden>
  • Date: Sun, 27 Jun 2004 10:08:10 -0400

I have a non-repeating NSTimer that is in the same method that it's calling. The NSTimer is initiated by a button-click and I need to stop it with a button click.

At [theTimer invalidate]; I get an out-of-scope runtime error, I believe this is because since it's non-repeating, it's already invalidated by the time the user clicks the button, but continues to repeat because it's always calling itself.

NSCalendarDate issue:
another error appears at adjust = [fireDate timeIntervalSinceDate:[NSCalendarDate calendarDate]];

it says it is out of scope also(I have to comment this line out to arrive at the other error). I really haven't a clue why. adjust is a value I want to subtract from TIMER_INTERVAL to ensure better timer accuracy. This is the output:

2004-06-27 09:56:31.018 NiceTimer[6803] updatemywindow.
2004-06-27 09:56:31.125 NiceTimer[6803] updatemywindow.

NiceTimer has exited due to signal 11 (SIGSEGV).

any suggestions would be greatly appreciated.
Michael

code:

- (IBAction)startStopTimer:(id)sender
{

NSCalendarDate *now;
NSCalendarDate *due;
if([[myButton title] isEqual:@"Start"])
{
// calculate seconds for both duration and interval
[self calculateSeconds];

if([self validateTimes])
{
theSignal = [[Signal alloc] init];

now = [NSCalendarDate calendarDate];
due = [now dateByAddingYears:0 months:0 days:0 hours:0 minutes:0 seconds:gIntervalSeconds];

[theSignal setInitialDate:now];
[theSignal setDueDate:[now dateByAddingYears:0 months:0 days:0 hours:0 minutes:0 seconds:gIntervalSeconds]];
[theSignal setNumberOfSignals:((int)gDurationSeconds/gIntervalSeconds)];
NSLog(@"theSignal: start: \n%@ \ndue: \n%@\n numSignals:%d",[theSignal initialDate], [theSignal dueDate], [theSignal signals]);
[myButton setTitle:@"Stop"];
if(countDownwards==YES)
[clockView setString:[NSString stringWithFormat:@"%f",[now timeIntervalSinceDate:[theSignal dueDate]]]];
else
[clockView setString:[NSString stringWithFormat:@"%f",[due timeIntervalSinceDate:[theSignal initialDate]]]];
[self disableSettings];
// [NSString stringWithFormat:@"0%d:",aMin]

theTimer = [NSTimer scheduledTimerWithTimeInterval:TIMER_INTERVAL target:self selector:@selector(updateMyWindow:) userInfo:nil repeats: NO];
}
}
else {

if(theTimer != nil) {
[theTimer invalidate]; /* debugger says this object is out of scope */ ///////////////
}
[myButton setTitle:@"Start"];
NSLog(@"got here startstop 1");
[self enableSettings];

}

}

- (void)updateMyWindow:(NSTimer *)aTimer
{
double adjust;

NSLog(@"updatemywindow.");

if(fireDate)
{
adjust = [fireDate timeIntervalSinceDate:[NSCalendarDate calendarDate]]; /* debugger says this var is out of scope */ ///////////////
NSLog(@"adjust: %f", adjust );
}

fireDate = [NSCalendarDate calendarDate];
aTimer = [NSTimer scheduledTimerWithTimeInterval:TIMER_INTERVAL target:self selector:@selector(updateMyWindow:) userInfo:nil repeats: NO];
//[aTimer setFireDate:[NSDate dateWithTimeIntervalSinceNow:TIMER_INTERVAL]];
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: NSDrawer returning large NSSize values
  • Next by Date: Re: NSDrawer returning large NSSize values
  • Previous by thread: Re: NSDrawer returning large NSSize values
  • Next by thread: OpenGL, GLUT, and Mac
  • Index(es):
    • Date
    • Thread