I'm trying to implement a delegate following a protocol. I found that I had specify my protocol as inheriting NSObject to allow it to support the performSelector call.
However, now I'm trying to do a "performSelector:withObject:afterDelay:", and I'm continuing to get this warning. Looking at the header file, this is specified in a category NSObject(NSDelayedPerforming).
But how do I make my protocol conform to that?
Here's the warning message I'm getting:
Quote:
|
warning: '-performSelector:withObject:afterDelay:' not found in protocol(s)
|
Here's an example of what I'm doing with the Protocol:
Code:
@protocol MyProtocol <NSObject>
-(void)doSomething(id referingObject);
@end
@interface MyClass : NSObject {
id <MyProtocol> delegate;
}
@property (nonatomic, assign) id <MyProtocol>delegate;
@end
@implementation MyClass
-(void)callMyDelegate {
if( delegate && [delegate respondsToSelector:@selector(doSomething:)] ) {
[NSObject cancelPreviousPerformRequestsWithTarget:delegate
selector:@selector(doSomething:)
object:self];
[delegate performSelector:@selector(doSomething:)
withObject:self
afterDelay:0.1];
}
}
@end
Neither of these seem to work:
- @protocol MyProtocol <NSObject, NSDelayedPerforming>
- @protocol MyProtocol <NSObject, NSObject(NSDelayedPerforming)>
>
Any suggestions?
Thanks