• 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
question about selector as argument
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

question about selector as argument


  • Subject: question about selector as argument
  • From: "Ivan S. Kourtev" <email@hidden>
  • Date: Sat, 18 Jun 2005 09:34:48 -0400

Hi,

I have a somewhat silly question with a probably quick an easy (or maybe not so easy) answer that I can't seem to figure out.

I have a class method in one class. I want to pass this method to an object of another class to use as a callback. I have the code at the end of the message but it doesn't quite work. At runtime, it produces the following error messages and the application exits due to signal 5 (SIGTRAP):

*** -[foo aSelector:]: selector not recognized [self = 0x369670]
An uncaught exception was raised
*** -[foo aSelector:]: selector not recognized [self = 0x369670]
*** Uncaught exception: <NSInvalidArgumentException> *** -[foo aSelector:]: selector not recognized [self = 0x369670]


Why is this happening? I am missing something terribly simple, aren't I? I was able to get this to work by modifying the callback to take an NSNumber* argument, then using performSelector:withObject within but doSomething. But I am sure there must be another way to do what I want.

Thanks for any help.

-- ivan


@implementation foo // a foo object is to be called back ... - (void)callbackFunction:(int)x { /* define the callback */ } ... // inside some other method boo* b; ... [b doSomething:self withCallBack:@selector( callbackFunction: )] ... ... #end


@implementation boo ... - (void)doSomething:(id)anObject withCallBack:(SEL)aSelector { ... [anObject aSelector:10]; ... } ... @end



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: question about selector as argument
      • From: Sherm Pendley <email@hidden>
    • Re: question about selector as argument
      • From: Andy Lee <email@hidden>
  • Prev by Date: Re: Does NSURLConnection automatically decode gzip'd data?
  • Next by Date: Re: How to find an over-released object?
  • Previous by thread: Re: How to find an over-released object?
  • Next by thread: Re: question about selector as argument
  • Index(es):
    • Date
    • Thread