I have a Swift function public func doSomething( aKey: String, completed: @escaping (AModel?, TagError?)->()) {}
that needs to be exposed to Objective C code for consumption. I have created an Objective C class wrapper like
@objc
public func doSomethingObjCWrapper(aKey : String) {
anObject.doSomething(aKey: aKey) { (modelA, error) in
if let whtModel = modelA {
// All good
DispatchQueue.main.async {
print("ok")
}
} else {
print("\(error?.localizedDescription ?? "Unknown error")")
}
}
}
to be called from Objective C code. Whenever the code gets triggered, I will always get EXC_BAD_ACCESS error in anObject.doSomething line. Any lead will be much appreciated.
is anObject
conform the NSObject
protocol?
if not, you can try this way because of the root class of most Objective-C class hierarchies, from which subclasses inherit a basic interface to the runtime system and the ability to behave as Objective-C objects
Reference https://developer.apple.com/documentation/objectivec/nsobject
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.