• 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: Alternative reference to self?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Alternative reference to self?


  • Subject: Re: Alternative reference to self?
  • From: email@hidden
  • Date: Sun, 12 Jan 2003 13:59:22 +0100

dimanche 12 janvier 2003, ` 11:59 AM, Dale Gillard a icrit :

Hi all

I need to check when a user's Mac sleeps and wakes so I can start and stop a timer. I've used the code in Fire as a guide based on a message from Eric in the archives. It works fine except that it won't accept a reference to [self ...] (my app's controller):

// Start of snippet
void sleepNotification( void * refcon, io_service_t service, natural_t messageType, void * messageArgument )
{
switch( messageType )
{
case kIOMessageSystemWillSleep:
[self stopRecentItemsTimer]; // Compiler warning - `self' undeclared (first use in this function).
IOAllowPowerChange( powerConnection, (long) messageArgument );
break;
...
// End of snippet

From the function prototype, I would guess that refCon is an user value that can be set when you set the notification callback.

If this is the case, the usual solution is to cast your self to a void * and then within your seleepNotification, do the reverse cast against the appropriate class and that's it.
_______________________________________________
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.
References: 
 >Alternative reference to self? (From: Dale Gillard <email@hidden>)

  • Prev by Date: Re: Notes about WebCore
  • Next by Date: Re: Aqua Human Interface and Safari
  • Previous by thread: Alternative reference to self?
  • Next by thread: NSTextView
  • Index(es):
    • Date
    • Thread