The following objc code handles the NSException raised by NSPredicate (the documentation doesn't say anything about NSException)
@try {
NSPredicate* predicate = [NSPredicate predicateWithFormat:@"incorrect_predicate like" argumentArray:nil];
NSLog(@"no problem");
}
@catch (NSException* exception) {
NSLog(@"exception %@", exception);
}The swift code raises NSException and seems impossible to catch the error
do {
let predicate = try NSPredicate(format:"a like", argumentArray:[])
} catch {
// never called
}How do I fix this problem without writing objc to catch NSException and raises swifth ErrorType?
Should be useful if NSPredicate declaration contains the "throws" clause and correctly handle the NSException
public class NSPredicate : NSObject, NSSecureCoding, NSCoding, NSCopying {
public init(format predicateFormat: String, argumentArray arguments: [AnyObject]?) throws
...
}