ObjC method: -(id)objectFromData:(NSData *)data error:(NSError *__autoreleasing *)error
Swift translated Method: func object(from data: Data!) throws -> Any
I am calling this translated func VIA do try Catch in swift. objC implementation of 'objectFromData' is
-(id)objectFromData:(NSData *)data error:(NSError *__autoreleasing *)error
{
*error = [NSError errorWithText:@"Unable to get Data, Please try later"];
return @"testing";
}
I am accessing like
let objCVar : ParserBase = ParserBase()
do {
try objCVar.object(from: data)
} catch {
print("Catched ObjC Error")
}
Error is not catched this way. Please guide how to get objc NSerror in above case.
Note: I can't use change objC method to 'Void' method to avoid throws translation because of enterprise scope of application.