• 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
Invoking protocol method on the main thread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Invoking protocol method on the main thread


  • Subject: Invoking protocol method on the main thread
  • From: Graham Cox <email@hidden>
  • Date: Fri, 16 Nov 2012 10:17:57 +1100

Hi all,


I have a formal protocol for a notification callback I want to make. The protocol inherits the NSObject protocol.

The caller accepts only objects conforming to this protocol as its delegate. When it's time to invoke the callback, I'd like to do so on the main thread, since the caller can be running on another thread. But -performSelectorOnMainThread:withObject:waitUntilDone: is not part of the NSObject protocol, it's part of the methods of NSObject, so my code won't compile because id<MyProtocol> objects don't include this method.

How can I invoke a method of my protocol on the main thread?


@protocol MyProtocol<NSObject>

- (void)		foo:(Caller*) caller;

...


@interface Caller : NSObject

@property (assign) id<MyProtocol>	delegate;

...



[self.delegate performSelectorOnMainThread:@selector(foo) withObject:self waitUntilDone:NO];		// method not found




--Graham



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Invoking protocol method on the main thread
      • From: Seth Willits <email@hidden>
    • Re: Invoking protocol method on the main thread
      • From: Greg Parker <email@hidden>
  • Prev by Date: Location permission alert self-dismisses
  • Next by Date: Re: Invoking protocol method on the main thread
  • Previous by thread: Location permission alert self-dismisses
  • Next by thread: Re: Invoking protocol method on the main thread
  • Index(es):
    • Date
    • Thread