• 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: Callbacks in C libraries
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Callbacks in C libraries


  • Subject: Re: Callbacks in C libraries
  • From: Eric Shepherd <email@hidden>
  • Date: Sat, 14 Jun 2003 20:47:44 -0400

On Saturday, June 14, 2003, at 08:25 PM, Bill Cheeseman wrote:

This is often done by passing self in a userInfo parameter to the function,
so that code within the function can refer to self and its instance
variables and accessors. If pRecord in your callback function is equivalent
to a Carbon userInfo parameter, you're all set. Otherwise, you might have to
use a global static variable, or something like that.

What I've discovered is that I can prototype my callback in my class's header file, then actually include my callback function right inside the method that results in it being called, like this:

- (int) doScan: (ConfigRec *)cfgRec {
int CallbackFunc(ConfigRec *cfgRec, const DataRec *pRecord) {
[fileList addObject: [NSString stringWithCString: pRecord->filename]];
// More code here
return 0;
}

RunFileScan(cfgRec, CallbackFunc);
}

This works like a charm.

--
Eric Shepherd
Owner
Syndicomm
http://www.syndicomm.com
_______________________________________________
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.

  • Follow-Ups:
    • Re: Callbacks in C libraries
      • From: Prachi Gauriar <email@hidden>
  • Prev by Date: Re: [ANN] NSTableView Assistant
  • Next by Date: Re: Callbacks in C libraries
  • Previous by thread: Re: Callbacks in C libraries
  • Next by thread: Re: Callbacks in C libraries
  • Index(es):
    • Date
    • Thread