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

Reply via email to