Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CFRunLoopTimerCallBack by reference?



Can argument 6 of 'CFRunLoopTimerCreate' somehow be a reference, or is a const compile-time string the only possibility?

That argument is not supposed to be a string at all -- it's a function pointer.


Given callback functions (of yours) such as:

void MyFirstCallBack(CFRunLoopTimerRef timer, void *info)
{
...
}

void MySecondCallBack(CFRunLoopTimerRef timer, void *info)
{
...
}
...you can pass around the addresses of these functions in variables of type CFRunLoopTimerCallBack.


	CFRunLoopTimerCallBack callbackRef = &MyFirstCallBack;

Cheers,

--Dave


On Mar 10, 2007, at 9:51 PM, led248 wrote:

I need to dispatch a lot of CFRunLoop timers with callbacks to several different functions. I'd like to write a single dispatch function that can specify the callback by *reference* rather than by name. I've never seen this done. Is it possible?

For example:

char* callbackRef = "myCallback";

CFRunLoopTimerRef timer = CFRunLoopTimerCreate (
/* CFAllocatorRef allocator */ kCFAllocatorDefault,
/* CFAbsoluteTime fireDate */ CFAbsoluteTimeGetCurrent() + delay,
/* CFTimeInterval interval */ 0, // 0 = fire once then invalidate
/* CFOptionFlags flags */ 0,
/* CFIndex order */ 0,
/* CFRunLoopTimerCallBack callout */ callbackRef, //----- nooooo way!
/* CFRunLoopTimerContext *context */ &context );


Can argument 6 of 'CFRunLoopTimerCreate' somehow be a reference, or is a const compile-time string the only possibility?

Any suggestions much appreciated!

_______________________________________________ Do not post admin requests to the list. They will be ignored. Carbon-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden
References: 
 >CFRunLoopTimerCallBack by reference? (From: led248 <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.