我有两个类A
和B
。我有一个删除将变量从A
传递到B
。我试着从B
到A
,让我可以从B
控制A
。我试图创建另一个委托,但它不起作用。由于我已经在B.h中导入A.h,所以我不能在A.h.中导入B.h。我应该如何设置自定义委托的两种方式?ios两种方式自定义代理
A.H
@protocol SoundDetectDelegate <NSObject>
-(void)update_from_sound: (SKSpriteNode*) node;
@end
@interface SoundDetect : NSObject
@property (nonatomic, weak) id <SoundDetectDelegate> delegate;
+ (id)sharedInstance;
-(void)beat;
@end
B.h
@interface HelloScene : SKScene <SoundDetectDelegate>
@property(nonatomic, strong) SoundDetect* sd;
@property(nonatomic, strong)Song* song;
@end
这是一种方式代表。
我想有一些像在B.h:
@protocol SceneDelegate <NSObject>
-(void)cancel_thread;
@end
@interface HelloScene : SKScene <SoundDetectDelegate>
@property(nonatomic, strong) SoundDetect* sd;
@property(nonatomic, strong)Song* song;
@end
,但我不能有@interface SoundDetect : NSObject <SceneDelegate>
回历中
将变量从B
传递到A
的主要目的是我要发送一个变量到A
,以便A
可以取消它的当前线程。
感谢
B到A? – 2015-01-21 05:00:58