这是我的Swift课:
class MyClass : NSObject {
public var inAppMessagesController: MPInAppMessagesController!
fun myFunction() {
self.inAppMessagesController.inAppInteractionDelegate = self // Error in this line - Cannot assign value of type 'MyClass' to type 'MPInAppMessageControllerDelegate?'
}
}
extension MyClass : MPInAppMessageControllerDelegate {
// Functions
}
如评论中所述,这是错误-
在无法将类型“ MyClass”的值分配给类型 “ MPInAppMessageControllerDelegate?”
Objective-C
类 MPInAppMessagesController 中的inAppInteractionDelegate :
@interface MPInAppMessagesController : NSObject
@property (nonatomic, weak, nullable) id <MPInAppMessageControllerDelegate> inAppInteractionDelegate;
@end
在 MPInAppMessagesController.h 中声明的MPInAppMessageControllerDelegate :
@protocol MPInAppMessageControllerDelegate<NSObject>
// Functions
@end
答案 0 :(得分:0)
唯一缺少的部分是您需要将此类包含在桥接文件中
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$("#autocomplete").autocomplete({
source: availableTags
});
转到此处查看SwiftObjc