Hi, Muthu. This is a longstanding issue with Operation—the Objective-C name of the property is just "executing", but the KVO keys that the implementors used is "isExecuting". Swift isn't set up to deal with this difference.
Fortunately, the base implementation of Operation already knows how to send the KVO notifications, so you shouldn't have to override these properties at all. If you still want to for some other reason, you can call super instead of storing to a private property. Hope that helps, Jordan > On Jun 13, 2017, at 06:40, somu subscribe via swift-users > <swift-users@swift.org> wrote: > > Hi, > > I am having trouble using KeyPath to KVC (Key Value Code) in Swift 4. > > I have a subclass of Operation and I am overriding the isFinished and > isExecuting property. > > Problem: > - When I use KeyPath, the completionBlock of the operation is not invoked. > - However when I use String instead of KeyPath, the completionBlock is > invoked. > > Questions: > - Am I missing something ? > - Is there a way to fix it using KeyPath ? > > Code: > > override var isExecuting : Bool { > > get { > return _executing //property in the class > } > > set { > willChangeValue(for: \.isExecuting) > _executing = newValue > didChangeValue(for: \.isExecuting) > } > } > > override var isFinished : Bool { > > get { > return _finished //property in the class > } > > set { > willChangeValue(for: \.isFinished) > _finished = newValue > didChangeValue(for: \.isFinished) > } > } > > > Configuration: > - Xcode - 9.0 beta (9M136h) > - Tested on Simulator (iOS 11) > - macOS Sierra - 10.12.5 (16F73) > > > Thanks and Regards, > Muthu > _______________________________________________ > swift-users mailing list > swift-users@swift.org > https://lists.swift.org/mailman/listinfo/swift-users
_______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users