I'm getting an error stating: Property 'clientChatLoad' not found on object of type 'DataManager' when using the following implementation:
#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)
}
}
}
...
@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"
...
From what I understand adding @class DataManager
to my Objective C class as well as @objc
before class func clientChatLoad
should expose the Swift code to my Objective C class... but I still receive an error. What might I have overlooked?
At first I thought your code was just some sort of misprint, but over the course of discussion in the comments I have come to realize that it is real and that you are attempting to put Swift code into an Objective-C file (namely AppDelegate.m). You cannot do that! An Objective-C file must be written entirely in Objective-C!
I would question whether you really even need a hybrid app (an app written in two languages). Your life will be much simpler if you pick just one language and write the whole app in that language. But if you are going to have a hybrid app, you need to learn Objective-C and write the Objective-C in Objective-C.