gpt4 book ai didi

ios - 如何使 Objective-C 类符合 Swift 中定义的协议(protocol)?

转载 作者:行者123 更新时间:2023-11-30 11:26:21 27 4
gpt4 key购买 nike

我有一个用 Swift 编写的类,我在其中定义了一个协议(protocol):

protocol PhotoIngestionDelegate {
func pictureTaken()
}

我试图让一个用 Objective-C 编写的类(CameraViewController)符合这个协议(protocol)。

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() ,但我似乎无法让委托(delegate)连接工作。在 CameraViewController.h 中,我发现它找不到“PhotoIngestionDelegate”的协议(protocol)定义

最佳答案

试试这个

@objc protocol PhotoIngestionDelegate {

}

关于ios - 如何使 Objective-C 类符合 Swift 中定义的协议(protocol)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50705525/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com