我有这个简单的课程
测试视图控制器.h
#import <UIKit/UIKit.h>
#import "ClassB.h"
@protocol TestViewControllerDelegate <NSObject>
-(void)hello;
@end
@interface TestViewController : UIViewController
@property (nonatomic , weak) id<TestViewControllerDelegate> delegate;
@end
测试视图控制器.m
#import "TestViewController.h"
@interface TestViewController ()
@end
@implementation TestViewController
@synthesize delegate = _delegate;
- (void)viewDidLoad
{
[super viewDidLoad];
/******* WHAT SHOULD I WRITE HERE?!?? *****/
[self.delegate hello];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
@end
另一个类:
B类.h
#import <Foundation/Foundation.h>
#import "TestViewController.h"
@interface ClassB : NSObject <TestViewControllerDelegate>
@end
B类.m
#import "ClassB.h"
@implementation ClassB
-(void)hello
{
NSLog(@"HELLO!");
}
@end
现在我需要创建 ClassB 的实例并将这个实例设置为 TestViewContoller 的委托,但我不知道我需要写什么!你能帮助我吗?