我在库中有一个Obj C协议......
@protocol DataWriter <NSObject>
- (void) writeData:(NSData*)data;
@end
...我想在Swift 3.1中使用:
class Streamer: NSObject, DataWriter {
...
// MARK: - DataWriter
func write(_ data: Data) throws {
// write data
throw NSError(domain: "", code: 1, userInfo: nil)
}
}
这没有错误抛出工作正常,但在这里编译器抱怨Candidate throws, but protocol does not allow it
,我完全得到。我如何更改协议以便在writeData
?