KVC - KeyPath in Operation

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

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

Thanks a lot Jordan for pointing out the root cause.

The underlying executing and finished properties are readonly properties.

For an Asynchronous operation I had to override it tell when the asynchronous operation completes.

Since they are readonly properties I am unable to call the super on them to set values.

I can still use String, was just wondering if there was a way to do it using KeyPath. It is more out of enthusiasm to try out the KeyPath feature in the project :slight_smile:

Would it be appropriate to file a bug report for the implementation of Operation ?

Thanks and regards,
Muthu

···

On 14 Jun 2017, at 1:32 AM, Jordan Rose <jordan_rose@apple.com> wrote:

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 <mailto: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 <mailto:swift-users@swift.org>
https://lists.swift.org/mailman/listinfo/swift-users

Hi Somu,

You can certainly file a bug for us. It may be something we are already tracking or already fixed, but the bug report will let us double check that.

Thanks,
- Tony

···

On Jun 13, 2017, at 12:33 PM, somu subscribe via swift-users <swift-users@swift.org> wrote:

Thanks a lot Jordan for pointing out the root cause.

The underlying executing and finished properties are readonly properties.

For an Asynchronous operation I had to override it tell when the asynchronous operation completes.

Since they are readonly properties I am unable to call the super on them to set values.

I can still use String, was just wondering if there was a way to do it using KeyPath. It is more out of enthusiasm to try out the KeyPath feature in the project :slight_smile:

Would it be appropriate to file a bug report for the implementation of Operation ?

Thanks and regards,
Muthu

On 14 Jun 2017, at 1:32 AM, Jordan Rose <jordan_rose@apple.com <mailto:jordan_rose@apple.com>> wrote:

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 <mailto: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 <mailto: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

Hi Tony,

Thank you so much I have a filed a bug for it under Foundation.

Thanks and regards,
Muthu

···

On 15 Jun 2017, at 8:27 AM, Tony Parker <anthony.parker@apple.com> wrote:

Hi Somu,

You can certainly file a bug for us. It may be something we are already tracking or already fixed, but the bug report will let us double check that.

Thanks,
- Tony

On Jun 13, 2017, at 12:33 PM, somu subscribe via swift-users <swift-users@swift.org> wrote:

Thanks a lot Jordan for pointing out the root cause.

The underlying executing and finished properties are readonly properties.

For an Asynchronous operation I had to override it tell when the asynchronous operation completes.

Since they are readonly properties I am unable to call the super on them to set values.

I can still use String, was just wondering if there was a way to do it using KeyPath. It is more out of enthusiasm to try out the KeyPath feature in the project :slight_smile:

Would it be appropriate to file a bug report for the implementation of Operation ?

Thanks and regards,
Muthu

On 14 Jun 2017, at 1:32 AM, Jordan Rose <jordan_rose@apple.com> wrote:

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

Hi Tony and Somu,

I have an open radar for this one which has been outstanding for a few months.

Radar #32191242

Hope this helps.

- Rod

···

On 15 Jun 2017, at 10:27 am, Tony Parker via swift-users <swift-users@swift.org> wrote:

Hi Somu,

You can certainly file a bug for us. It may be something we are already tracking or already fixed, but the bug report will let us double check that.

Thanks,
- Tony

On Jun 13, 2017, at 12:33 PM, somu subscribe via swift-users <swift-users@swift.org <mailto:swift-users@swift.org>> wrote:

Thanks a lot Jordan for pointing out the root cause.

The underlying executing and finished properties are readonly properties.

For an Asynchronous operation I had to override it tell when the asynchronous operation completes.

Since they are readonly properties I am unable to call the super on them to set values.

I can still use String, was just wondering if there was a way to do it using KeyPath. It is more out of enthusiasm to try out the KeyPath feature in the project :slight_smile:

Would it be appropriate to file a bug report for the implementation of Operation ?

Thanks and regards,
Muthu

On 14 Jun 2017, at 1:32 AM, Jordan Rose <jordan_rose@apple.com <mailto:jordan_rose@apple.com>> wrote:

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 <mailto: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 <mailto:swift-users@swift.org>
https://lists.swift.org/mailman/listinfo/swift-users

_______________________________________________
swift-users mailing list
swift-users@swift.org <mailto: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

Hi Rod,

Thanks, we’re looking into it.

- Tony

···

On Jun 15, 2017, at 9:14 PM, Rod Brown <rodney.brown6@icloud.com> wrote:

Hi Tony and Somu,

I have an open radar for this one which has been outstanding for a few months.

Radar #32191242

Hope this helps.

- Rod

On 15 Jun 2017, at 10:27 am, Tony Parker via swift-users <swift-users@swift.org <mailto:swift-users@swift.org>> wrote:

Hi Somu,

You can certainly file a bug for us. It may be something we are already tracking or already fixed, but the bug report will let us double check that.

Thanks,
- Tony

On Jun 13, 2017, at 12:33 PM, somu subscribe via swift-users <swift-users@swift.org <mailto:swift-users@swift.org>> wrote:

Thanks a lot Jordan for pointing out the root cause.

The underlying executing and finished properties are readonly properties.

For an Asynchronous operation I had to override it tell when the asynchronous operation completes.

Since they are readonly properties I am unable to call the super on them to set values.

I can still use String, was just wondering if there was a way to do it using KeyPath. It is more out of enthusiasm to try out the KeyPath feature in the project :slight_smile:

Would it be appropriate to file a bug report for the implementation of Operation ?

Thanks and regards,
Muthu

On 14 Jun 2017, at 1:32 AM, Jordan Rose <jordan_rose@apple.com <mailto:jordan_rose@apple.com>> wrote:

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 <mailto: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 <mailto:swift-users@swift.org>
https://lists.swift.org/mailman/listinfo/swift-users

_______________________________________________
swift-users mailing list
swift-users@swift.org <mailto:swift-users@swift.org>
https://lists.swift.org/mailman/listinfo/swift-users

_______________________________________________
swift-users mailing list
swift-users@swift.org <mailto:swift-users@swift.org>
https://lists.swift.org/mailman/listinfo/swift-users

Hi Rod and Tony,

Thanks a lot !

Regards,
Muthu

···

On 17 Jun 2017, at 12:11 AM, Tony Parker <anthony.parker@apple.com> wrote:

Hi Rod,

Thanks, we’re looking into it.

- Tony

On Jun 15, 2017, at 9:14 PM, Rod Brown <rodney.brown6@icloud.com> wrote:

Hi Tony and Somu,

I have an open radar for this one which has been outstanding for a few months.

Radar #32191242

Hope this helps.

- Rod

On 15 Jun 2017, at 10:27 am, Tony Parker via swift-users <swift-users@swift.org> wrote:

Hi Somu,

You can certainly file a bug for us. It may be something we are already tracking or already fixed, but the bug report will let us double check that.

Thanks,
- Tony

On Jun 13, 2017, at 12:33 PM, somu subscribe via swift-users <swift-users@swift.org> wrote:

Thanks a lot Jordan for pointing out the root cause.

The underlying executing and finished properties are readonly properties.

For an Asynchronous operation I had to override it tell when the asynchronous operation completes.

Since they are readonly properties I am unable to call the super on them to set values.

I can still use String, was just wondering if there was a way to do it using KeyPath. It is more out of enthusiasm to try out the KeyPath feature in the project :slight_smile:

Would it be appropriate to file a bug report for the implementation of Operation ?

Thanks and regards,
Muthu

On 14 Jun 2017, at 1:32 AM, Jordan Rose <jordan_rose@apple.com> wrote:

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

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Hi Rod and Tony,

This looks like it has been fixed. I tried replacing the String with the KeyPath and (NS)Operation seems to work like a charm.

Thank you so much guys !!!

Love KeyPath … am so excited. :smiley:

I will close the bug report that I created.

Regards,
Muthu

···

On 17 Jun 2017, at 8:02 AM, somu subscribe <somu.subscribe@gmail.com> wrote:

Hi Rod and Tony,

Thanks a lot !

Regards,
Muthu

On 17 Jun 2017, at 12:11 AM, Tony Parker <anthony.parker@apple.com <mailto:anthony.parker@apple.com>> wrote:

Hi Rod,

Thanks, we’re looking into it.

- Tony

On Jun 15, 2017, at 9:14 PM, Rod Brown <rodney.brown6@icloud.com <mailto:rodney.brown6@icloud.com>> wrote:

Hi Tony and Somu,

I have an open radar for this one which has been outstanding for a few months.

Radar #32191242

Hope this helps.

- Rod

On 15 Jun 2017, at 10:27 am, Tony Parker via swift-users <swift-users@swift.org <mailto:swift-users@swift.org>> wrote:

Hi Somu,

You can certainly file a bug for us. It may be something we are already tracking or already fixed, but the bug report will let us double check that.

Thanks,
- Tony

On Jun 13, 2017, at 12:33 PM, somu subscribe via swift-users <swift-users@swift.org <mailto:swift-users@swift.org>> wrote:

Thanks a lot Jordan for pointing out the root cause.

The underlying executing and finished properties are readonly properties.

For an Asynchronous operation I had to override it tell when the asynchronous operation completes.

Since they are readonly properties I am unable to call the super on them to set values.

I can still use String, was just wondering if there was a way to do it using KeyPath. It is more out of enthusiasm to try out the KeyPath feature in the project :slight_smile:

Would it be appropriate to file a bug report for the implementation of Operation ?

Thanks and regards,
Muthu

On 14 Jun 2017, at 1:32 AM, Jordan Rose <jordan_rose@apple.com <mailto:jordan_rose@apple.com>> wrote:

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 <mailto: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 <mailto:swift-users@swift.org>
https://lists.swift.org/mailman/listinfo/swift-users

_______________________________________________
swift-users mailing list
swift-users@swift.org <mailto:swift-users@swift.org>
https://lists.swift.org/mailman/listinfo/swift-users

_______________________________________________
swift-users mailing list
swift-users@swift.org <mailto:swift-users@swift.org>
https://lists.swift.org/mailman/listinfo/swift-users

Great, thanks for the update!

- Tony

···

On Oct 28, 2017, at 2:35 AM, somu subscribe <somu.subscribe@gmail.com> wrote:

Hi Rod and Tony,

This looks like it has been fixed. I tried replacing the String with the KeyPath and (NS)Operation seems to work like a charm.

Thank you so much guys !!!

Love KeyPath … am so excited. :smiley:

I will close the bug report that I created.

Regards,
Muthu

On 17 Jun 2017, at 8:02 AM, somu subscribe <somu.subscribe@gmail.com> wrote:

Hi Rod and Tony,

Thanks a lot !

Regards,
Muthu

On 17 Jun 2017, at 12:11 AM, Tony Parker <anthony.parker@apple.com> wrote:

Hi Rod,

Thanks, we’re looking into it.

- Tony

On Jun 15, 2017, at 9:14 PM, Rod Brown <rodney.brown6@icloud.com> wrote:

Hi Tony and Somu,

I have an open radar for this one which has been outstanding for a few months.

Radar #32191242

Hope this helps.

- Rod

On 15 Jun 2017, at 10:27 am, Tony Parker via swift-users <swift-users@swift.org> wrote:

Hi Somu,

You can certainly file a bug for us. It may be something we are already tracking or already fixed, but the bug report will let us double check that.

Thanks,
- Tony

On Jun 13, 2017, at 12:33 PM, somu subscribe via swift-users <swift-users@swift.org> wrote:

Thanks a lot Jordan for pointing out the root cause.

The underlying executing and finished properties are readonly properties.

For an Asynchronous operation I had to override it tell when the asynchronous operation completes.

Since they are readonly properties I am unable to call the super on them to set values.

I can still use String, was just wondering if there was a way to do it using KeyPath. It is more out of enthusiasm to try out the KeyPath feature in the project :slight_smile:

Would it be appropriate to file a bug report for the implementation of Operation ?

Thanks and regards,
Muthu

On 14 Jun 2017, at 1:32 AM, Jordan Rose <jordan_rose@apple.com> wrote:

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

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users