KVC dependent classes


(David Hart) #1

I was looking through Foundation for stuff to do and saw NSProgress, NSExpression and NSSortDescriptor. They seem to be most reliant on KVC, and as KVC is not available without the Objective-C runtime, I’m not sure what those classes are doing here. Are those classes doomed to be dropped? Or is there another way to implement them?

David.


(Tony Parker) #2

Hi David,

It’s likely that we’ll have to come up with some alternative API in these cases. For example, in NSProgress I could imagine a callback for progress updates instead of observing the properties. It’s not ideal but I don’t think we want to undertake a reinvention of KVO when we do not have the Objective-C runtime present (so much of it relies on that dynamic behavior).

- Tony

···

On Mar 14, 2016, at 4:14 PM, David Hart via swift-corelibs-dev <swift-corelibs-dev@swift.org> wrote:

I was looking through Foundation for stuff to do and saw NSProgress, NSExpression and NSSortDescriptor. They seem to be most reliant on KVC, and as KVC is not available without the Objective-C runtime, I’m not sure what those classes are doing here. Are those classes doomed to be dropped? Or is there another way to implement them?

David.
_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


(David Hart) #3

Sorry, I said NSProgress but I meant NSPredicate. I personally can't even imagine what a alternative API for NSPredicate would look like :thinking:

···

On 15 Mar 2016, at 00:21, Tony Parker <anthony.parker@apple.com> wrote:

Hi David,

It’s likely that we’ll have to come up with some alternative API in these cases. For example, in NSProgress I could imagine a callback for progress updates instead of observing the properties. It’s not ideal but I don’t think we want to undertake a reinvention of KVO when we do not have the Objective-C runtime present (so much of it relies on that dynamic behavior).

- Tony

On Mar 14, 2016, at 4:14 PM, David Hart via swift-corelibs-dev <swift-corelibs-dev@swift.org> wrote:

I was looking through Foundation for stuff to do and saw NSProgress, NSExpression and NSSortDescriptor. They seem to be most reliant on KVC, and as KVC is not available without the Objective-C runtime, I’m not sure what those classes are doing here. Are those classes doomed to be dropped? Or is there another way to implement them?

David.
_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


(Brent Royal-Gordon) #4

Sorry, I said NSProgress but I meant NSPredicate. I personally can't even imagine what a alternative API for NSPredicate would look like :thinking:

Use reflection.

Match against only dictionaries with string keys.

Match against only objects conforming to some dictionary-with-string-keys-like protocol.

Match against only objects conforming to an NSKeyValueCoding protocol with a `value(forKey:)` requirement.

Don't actually implement matching; just use it as an abstraction for things like CloudKit and Core Data.

There are options.

···

--
Brent Royal-Gordon
Architechies