关键字:@protocol
一共两个Controller,分别为a、b
//---------------------Controller a---------------------------
#import <UIKit/UIKit.h>
@protocol aaDelegate;
@interface a : UIViewController
@property (nonatomic,retain) id<aaDelegate> delegate;
@end
@protocol aaDelegate <NSObject>
-(void)didBack;
@end
@implementation a
- (void)viewDidLoad
{
[self.delegate didBack];
}
//---------------------Controller b---------------------------
#import "a.h"
@interface b : UIViewController<aaDelegate>
{
a *a;
}
@property(nonatomic,retain)a *a;
@end
@implementation b
@synthesize a;
- (void)viewDidLoad
{
self.a = [[a alloc] init];
self.a.delegate = self;
}
-(void)didBack
{
//执行内容
}
@end