我看到了 Flower an MyGarden 的示例,但是当我尝试制作类似的东西时它不起作用。我的代码:
类A.h:
#import <Foundation/Foundation.h>
@protocol CommDelegate <NSObject>
@required
-(void)funcB;
@end
@interface ClassA : NSObject
{
id <CommDelegate> delegate;
}
@property (retain) id delegate;
-(void)funcB;
@end
类A.m
#import "ClassA.h"
@implementation ClassA
-(void) start
{
[[self delegate] funcB];
}
@end
B类.h
#import <Foundation/Foundation.h>
#import "ClassA.h"
@interface ClassB : NSObject <CommDelegate>
@end
B类.m
#import "ClassB.h"
@implementation ClassB
-(void)funcB
{
NSLog(@"HELLO!");
}
@end
主要是我在做:
ClassA* classa = [[ClassA alloc] init];
[classa start];
有人可以帮助我,并告诉我我做错了什么吗?