簡體   English   中英

如何使Objective-C類符合Swift中定義的協議?

[英]How to make an Objective-C class conform to a protocol defined in Swift?

我有一個用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 {

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM