Re: Alternative reference to self?
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.