You can create your own:
In MyView1.h:
@class MyView1;
@protocol MyView1Delegate <NSObject>
- (void)closeMyView1:(MyView1 *)myView1;
@end
@interface MyView1 : NSObject
{
id<MyView1Delegate> _delegate;
}
@property (assign, nonatomic, readwrite) id<MyView1Delegate> delegate;
...
@end
In MyView1.m:
@interface MyView1
@synthesize delegate = _delegate;
...
// The method that tells the delegate to close me
- (void)closeMe
{
....
if ([_delegate respondsToSelector:@selector(closeMyView1:)])
{
[_delegate closeMyView1:self];
}
}
@end
In AppDelegate.h:
#import "MyView1.h"
@interface AppDelegate <MyView1Delegate>
{
MyView1 *_myView1;
}
...
@end
In AppDelegate.m:
- (void)someCreateViewMethod
{
_myView1 = [[MyView1 alloc] initWithFrame:NSMakeRect(0, 0, 100, 200)];
[_myView1 setDelegate:self];
...
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…