Today I\'ve met one weird issue when I was trying to \'generalize\' my \'CoreData importing operations\'. It appeared that if I create a generic subclass of NSOperation the
In Xcode 7 generic NSOperation has been fixed: if I run this code in a playground it works:
protocol SomeProtocol {
// markup protocol
}
class GenericOperation: NSOperation {
let referenceToSomeTypeImplementingProtocol: SomeTypeImplementingProtocol
init(referenceToSomeTypeImplementingProtocol: SomeTypeImplementingProtocol) {
self.referenceToSomeTypeImplementingProtocol = referenceToSomeTypeImplementingProtocol
}
override func main() {
debugPrint("The GenericOperation main() method was called.")
}
}
class TypeImplementingSomeProtocol: SomeProtocol {
init() {
}
}
let operationQueue = NSOperationQueue()
let typeImplementingSomeProtocolInstance = TypeImplementingSomeProtocol()
let operation = GenericOperation(referenceToSomeTypeImplementingProtocol: typeImplementingSomeProtocolInstance)
operationQueue.addOperation(operation)