Created
December 25, 2012 12:44
-
-
Save Lewuathe/4373003 to your computer and use it in GitHub Desktop.
自作delegateメソッドの作り方 ref: http://qiita.com/items/d848e0756e15613e41c6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@class MyClass; | |
@protocol MyClassDelegate | |
@optional | |
-(void)optionDelegateMethod:(MyClass*)myClass; | |
@required | |
-(void)requiredDelegateMethod:(MyClass*)myClass; | |
@end | |
@interface MyClass : NSObject | |
@property id <MyClassDelegate> delegate; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)MyClassMethod{ | |
[self.delegate requireDelegateMethod:self]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface SomeViewController : UIViewController <MyClassDelegate>{ | |
MyClass *myClass; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)requiredDelegateMethod:(MyClass*)myClass{ | |
NSLog(@"requireDelegateMethod"); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment