I have two methods in my objective-c library that, after converting to Swift, seem to have the same method signature. They look like this: Objective-C:
- (void)doSomething:(UIViewController *)viewController __attribute__((deprecated)); - (BOOL)doSomething:(UIViewController *)viewController error:(NSError **)error;
From what I read about Swift conversion of methods using NSErrors + BOOL return values ββin Objective-C, these methods will have the following Swift method signatures:
func doSomething(viewController: UIViewController) func doSomething(viewController: UIViewController) throws
Since the first call is not really recommended in Objective-C, is there a way to force the calls made for this method to use the second signature (so that I can take advantage of the errors received)?
I am trying to call a method as follows:
do { try myObjectInstance.doSomething(self) } catch let error as NSError { print(error) }
This approach, apparently, by default refers to the first declaration, which gives me a warning that: a) the method is outdated and b) there is nothing to catch, because there are no errors.
Maixy source share