• 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
Re: Schedule a Method
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Schedule a Method


  • Subject: Re: Schedule a Method
  • From: David Emme <email@hidden>
  • Date: Mon, 6 Aug 2007 07:59:33 -0700


On Aug 6, 2007, at 3:46 AM, Andrew James wrote:

Is there a way to schedule a method to run in 24 hours or even directly by date, by schedule i mean that it wont be delayed by system sleep like NSTimer


I have a program that issues reminders of various things at various dates and times. There is always one NSTimer running, counting down to the alert time for the next reminder. This is how I handle machine sleep:

(1) at some appropriate initialization point, do:

// Register for machine sleep & wake notifications.
NSNotificationCenter *notCenter;
notCenter = [[NSWorkspace sharedWorkspace] notificationCenter];
[notCenter addObserver:self
			  selector:@selector(sleepObserver:)
			  name:NSWorkspaceWillSleepNotification
			object:nil];

[notCenter addObserver:self
			  selector:@selector(wakeObserver:)
			  name:NSWorkspaceDidWakeNotification
			object:nil];


(2) when the machine is about to go to sleep:

- (void)sleepObserver:(id)aNotification {
	// Invalidate the NSTimer
}

(3) when the machine wakes up again:

- (void)wakeObserver:(id)aNotification {
	// Take the earliest reminder off the queue, compute the new time
	// difference between "now" and when it should alert,
	// and start up an NSTimer accordingly.
}


HTH, -Dave -- A man who suffers before it is necessary suffers more than is necessary. - Seneca

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Schedule a Method (From: Andrew James <email@hidden>)

  • Prev by Date: Re: Resolution independent cursors
  • Next by Date: Re: CoreData can't handle booleans in metadata
  • Previous by thread: Re: Schedule a Method
  • Next by thread: Again drag with NSTableView
  • Index(es):
    • Date
    • Thread