gpt4 book ai didi

objective-c - 如何使 Swift 的协议(protocol)在 .h 文件中可见?

转载 作者:行者123 更新时间:2023-11-28 09:15:29 25 4
gpt4 key购买 nike

我有 3 个文件:

PLThreadViewController.swift

@objc protocol PLThreadViewDelegate {
func threadViewControlledWillDismiss(threadViewController: PLThreadViewController)
}

class PLThreadViewController: UIViewController {}

PLMessagesTableViewController.h

#import <UIKit/UIKit.h>

@interface PLMessagesTableViewController : UITableViewController <PLThreadViewDelegate>

@end

问题是:找不到 PLThreadViewDelegate 的协议(protocol)声明

当我尝试添加时:

#import "Module-Swift.h"

然后:

未找到 Module-Swift.h 文件。模块名称非常正确。我读到了名称中的空格、下划线等等。

最佳答案

Xcode 是否为您创建了桥接 header ?如果是这样,请查看 Xcode 在那里使用的命名,这将提示您如何命名“-Swift.h”文件。因此,如果您的桥接 header 名为 My_Project-Bridging-Header.h,则您自动生成的 Swift header 将为 My_Project-Swift.h。

关于objective-c - 如何使 Swift 的协议(protocol)在 .h 文件中可见?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27856821/

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