views:

36

answers:

1

Here is what I am trying to do:

id<MyDelegate> _delegate;
....
[_delegate performSelectorOnMainThread...]

@protocol MyDelegate <NSObject>
....

My problem is that performSelectorOnMainThread is defined in a category of NSObject so the compiler doesn't recognize it. I get: "warning: '-performSelectorOnMainThread:withObject:waitUntilDone:' not found in protocol(s)" I could cast the delegate but that defeats the purpose of the delegate. Any suggestions?

A: 

Declare your delegate as NSObject<MyDelegate> * _delegate;.

This tells the compiler that _delegate must be an instance of NSObject or subclass that must respond to the requirements of the MyDelegate protocol.

bbum
That did it. Thanks!
Tylerc230