home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / next / programm / 7998 < prev    next >
Encoding:
Internet Message Format  |  1993-01-06  |  1.1 KB

  1. Path: sparky!uunet!rosie!NeXT.com
  2. From: sam_s@NeXT.com (Sam Streeper)
  3. Newsgroups: comp.sys.next.programmer
  4. Subject: Re: Pointers to functions in method definitions
  5. Message-ID: <6164@rosie.NeXT.COM>
  6. Date: 6 Jan 93 05:10:45 GMT
  7. References: <C0CAtI.KqM@knot.ccs.queensu.ca>
  8. Sender: news@NeXT.COM
  9. Reply-To: sam_s@NeXT.com
  10. Lines: 23
  11.  
  12. alastair@hecate.phy.queensu.ca (A.B. McLean) writes:
  13. > I want to write a method that will accept a pointer to a C function.
  14.  
  15.  
  16. I would guess that this isn't directly possible; it looks like the Objective-C  
  17. runtime doesn't have the ability to encode data of type function pointer.
  18.  
  19. A couple of solutions might include passing the function pointer as an int  
  20. pointer and then casting it to a function pointer, or to remove the function  
  21. interface and pass a selector:
  22.  
  23. - invokeThisMethod:(SEL) aMethod
  24. {
  25.     [self perform: aMethod with:self];
  26.  
  27. }
  28.  
  29. If aMethod = @selector(foo:), this is roughly equivalent to [self foo:self].
  30.  
  31. -sam
  32. --
  33. Opinions expressed herein are not those of my employer.  They're not even
  34. mine.  They're probably wrong besides.  How did they get in here, anyway?
  35.