我有一个用Swift编写的类,其中定义了一个协议:
protocol PhotoIngestionDelegate {
func pictureTaken()
}
我试图让用Objective-C编写的类(CameraViewController)符合此协议。
CameraViewController.h:
#import <GSSDK/GSSDK.h>
@protocol PhotoIngestionDelegate;
@interface CameraViewController : GSKCameraViewController <PhotoIngestionDelegate>
@end
CameraViewController.m:
#import "CameraViewController.h"
#import <GSSDK/GSSDK.h>
#import "EditFrameViewController.h"
#import "Scan.h"
@interface CameraViewController<PhotoIngestionDelegate> ()
@property (nonatomic, strong) UIView *toolbar;
@property (nonatomic, strong) UIButton *cameraButton;
@end
@implementation CameraViewController
...
CameraViewController.m中的实现仍在继续,但是为了简洁起见,我将其切除。我知道我需要在CameraViewController.m中定义函数pictureTaken(),但似乎无法使委托连接正常工作。在CameraViewController.h中,我得到它
Cannot find protocol definition for 'PhotoIngestionDelegate'
。 最佳答案
尝试这个
@objc protocol PhotoIngestionDelegate {
}