I want to invoke a delegate in class method.
The example below obviously does not work, since the delegate is an instance variable that is accessed within a class method. (Error: instance variable 'delegate' accessed in class method)
Is there an alertnative?
My header file:
// MyClass.h
#import <Foundation/Foundation.h>
@protocol MyDelegate <NSObject>
-(void)update;
@end
@interface MyClass : NSObject
{
id<MyDelegate> delegate;
}
@property (nonatomic, retain) id delegate;
+(void)methodThatInvokesDelegate;
@end
My implementation file:
// MyClass.m
#import "MyClass.h"
@implementation MyClass
@synthesize delegate;
+(void)methodThatInvokesDelegate{
[delegate update];
}
@end