私はこの単純なクラスを持っています
TestViewController.h
#import <UIKit/UIKit.h>
#import "ClassB.h"
@protocol TestViewControllerDelegate <NSObject>
-(void)hello;
@end
@interface TestViewController : UIViewController
@property (nonatomic , weak) id<TestViewControllerDelegate> delegate;
@end
TestViewController.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
そして別のクラス:
ClassB.h
#import <Foundation/Foundation.h>
#import "TestViewController.h"
@interface ClassB : NSObject <TestViewControllerDelegate>
@end
ClassB.m
#import "ClassB.h"
@implementation ClassB
-(void)hello
{
NSLog(@"HELLO!");
}
@end
ここで、ClassB のインスタンスを作成して、このインスタンスを TestViewContoller のデリゲートとして設定する必要がありますが、何を書く必要があるのかわかりません! 手伝って頂けますか?