我想從完成塊發送回調監聽器。我啓動自定義回調UIView
&完成塊從父視圖控制器執行(其中UIView
子查看)。下面是代碼...(我不想使用代理)在ViewController.m
Objective-C回撥沒有與不幸的背景崩潰工作
-(void) exportCompletionBlock:(ExportCompletion)callback
{
if (callback) {
self.exportBlock = callback;
}
}
實施
的回撥宣言ViewController.h
typedef void(^ExportCompletion)(BOOL success, NSURL* url);
@property (nonatomic, copy) ExportCompletion exportBlock;
-(void) exportCompletionBlock:(ExportCompletion)callback;
初始化&的回撥實施(致電)
-(void)blockAlertAppear:(float)progress{
if(EXPORT_SESSION_COMPLETED!=progress)
doing something...
if(EXPORT_SESSION_COMPLETED==progress){
self.exportBlock(YES, mCompositor.url);
}
}
呼叫在uicustomview回操作... CustomUIView.m
-(void) initUIView{
[(ViewController*)[[self superview] nextResponder] exportCompletionBlock:^(BOOL success, NSURL *url) {
if (success) {
doing something...
}
}];
我可以在這裏使用委託,但我想用回電話。回電後我很新。我想知道爲什麼我有崩潰(它來自後臺 - 所以沒有理由)&我該如何優化代碼?