我收到一条错误消息:使用以下实现时,在“DataManager”类型的对象上找不到属性“clientChatLoad”:
AppDelegate.m
#import "IOS_Project_Name-Swift.h"
@class DataManager;
...
DataManager.clientChatLoad(0){ data, error in
guard data != nil else {
print(error)
return
}
guard let data = data else { return }
let json = JSON(data: data)
if let result = json["success"].bool{
if (result){
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(0.5 * Double(NSEC_PER_SEC))), dispatch_get_main_queue()) { () -> Void in
NSNotificationCenter.defaultCenter().postNotificationName("refreshChatDetails", object: nil, userInfo:nil)
}
}
}
数据管理器.swift
...
@objc class func clientChatLoad(_ chatId: Int, completionHandler: @escaping (Data?, NSError?) -> ()) -> URLSessionTask {
// AJ TO-DO
var defaults = UserDefaults.standard
let URL = Foundation.URL(string: chatUrl)!
var request = URLRequest(url: URL, cachePolicy: .reloadIgnoringLocalAndRemoteCacheData, timeoutInterval: 3.0)
request.httpMethod = "POST"
...
据我了解,添加@class DataManager
到我的 Objective C 类以及@objc
之前 class func clientChatLoad
应该将 Swift 代码暴露给我的 Objective C 类......但我仍然收到一个错误。我可能忽略了什么?