ios - 在 Swift 中移植 obj-c 委托(delegate)方法

标签 ios objective-c swift delegates

如何将这个可选的 obj-c 委托(delegate)方法移植到 swift?

- (void)popupStoreEventWasEmitted:(PopupStoreController *)controller withEvent:(NSString*)eventName withPayload:(NSDictionary *)payload;

我已经尝试了 AnyObject(可选的和必需的)、NSDictionary、Dictionary(可选的和必需的)、String 和 NSString(可选的和必需的)等所有可能的组合。但无论它指出什么错误:

/FastDev/Classes/TDTFinishingViewController.swift:884:14:方法“popupStoreEventWasEmitted(:withEvent:withPayload:)”提供的 Objective-C 方法“popupStoreEventWasEmitted:withEvent:withPayload:”与可选要求方法“popupStoreEventWasEmitted(: withEvent:withPayload:)' 在协议(protocol) 'PopupStoreControllerDelegate' 中

有什么地方可以让我找到 swift 委托(delegate)方法的样子吗?

最佳答案

如果您只是开始输入方法名称,Xcode 应该会自动完成它。我得到:

func popupStoreEventWasEmitted(controller: PopupStoreController!,
                               withEvent eventName: String!,
                               withPayload payload: [NSObject : AnyObject]!)
{

}

关于ios - 在 Swift 中移植 obj-c 委托(delegate)方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36522104/

相关文章:

android - 跨平台多人游戏(app)

ios - 在 Xcode 的 .plist 中定义 ENUM 值

json - Swift:将结构转换为 JSON?

objective-c - xcode 有错误线程 1 :Program received signal 'SIGABRT'

objective-c - 如何创建像 iOS 游戏 'Contre Jour' 一样的土地(山丘)?

ios - 错误 : "Message reply took too long" - WCSession Watch OS2

ios - UICollectionView 单元格快速重叠

ios - 在 iOS 中打开另一个应用程序

iphone - 测试您的 IOS 应用程序 - 对真正的应用程序内购买和最终编辑进行最终测试

iOS 6 Facebook 不工作