Reputation: 21
I have a Obj C protocol in a library...
@protocol DataWriter <NSObject>
- (void) writeData:(NSData*)data;
@end
...that I would like to use in Swift 3.1:
class Streamer: NSObject, DataWriter {
...
// MARK: - DataWriter
func write(_ data: Data) throws {
// write data
throw NSError(domain: "", code: 1, userInfo: nil)
}
}
This works fine without the error throwing, but here the compiler complains that Candidate throws, but protocol does not allow it
, which I totally get. How would I have to change the protocol so I can throw an error in writeData
?
Upvotes: 2
Views: 64