You will want to declare a delegate protocol for your class. An example of a delegate protocol and interface for class
Foo
might look like this:
@class Foo;
@protocol FooDelegate <NSObject>
@optional
- (BOOL)foo:(Foo *)foo willDoSomethingAnimated:(BOOL)flag;
- (void)foo:(Foo *)foo didDoSomethingAnimated:(BOOL)flag;
@end
@interface Foo : NSObject {
NSString *bar;
id <FooDelegate> delegate;
}
@property (nonatomic, retain) NSString *bar;
@property (nonatomic, assign) id <FooDelegate> delegate;
- (void)someAction;
@end
Don't forget to synthesize your properties in the @implementation
.
How to USE:
@interface SomeClass : SuperClass <FooDelegate> {}
Foo *obj = [[Foo alloc] init];
[obj setDelegate:self];
Reference:
http://stackoverflow.com/questions/645449/how-to-use-custom-delegates-in-objective-c
No comments:
Post a Comment