I've made an NSInputStream subclass, but when it gets to read the actual data I get the following exception.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -setDelegate: only defined for abstract class. Define -[EventusCore.FileUploadStream setDelegate:]!'
I am unable to override the the following property of NSStream abstract class:
unowned(unsafe) public var delegate: NSStreamDelegate?
Here is my class that inherits from NSInputStream
class InputStream : NSInputStream {
private var currentStatus: NSStreamStatus = .Closed
// override var delegate: NSStreamDelegate?
weak var delegate: NSStreamDelegate?
override func open() {
self.currentStatus = .Open
}
override func close() {
self.currentStatus = .Closed
}
override var streamStatus: NSStreamStatus {
return self.currentStatus
}
override var hasBytesAvailable: Bool {
return self.currentStatus == .Open
}
// MARK: NSInputStream and CFReadStream abstract method overrides
override func scheduleInRunLoop(aRunLoop: NSRunLoop, forMode mode: String) {
}
override func removeFromRunLoop(aRunLoop: NSRunLoop, forMode mode: String) {
}
}
Here is the error I am getting:
What am I doing wrong? Is this possible at all using Swift?