【发布时间】:2014-02-18 12:54:14
【问题描述】:
我在 iPhone 中制作了一个摄影应用程序,我有这 3 个类:ViewController、CaptureManager 和 ImgProcessor。
视图控制器:
-(IBAction)takePic:(id)sender{
images = [captureManager takeMultipleImagesWithCompletion:^{
//Some UI related code..
[imgProcessor process:images];
}];
}
捕获管理器:
-(NSArray *)takeMultipleImagesWithCompletion:^(void)completionHandler{
// take picture codes...
completionHandler();
return arrayOfImagesTaken;
}
到目前为止,它按预期工作:imgProcessor 处理由captureManager 拍摄的图像。但我不太明白这是如何工作的。 Bcos 在返回拍摄的图像数组之前,我调用了 completionHandler。这段代码是如何执行的?有没有更好的解决方案?
谢谢!
【问题讨论】:
标签: ios iphone objective-c objective-c-blocks