Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-6270] Accessing _kvcKeyPathString #4494

Closed
swift-ci opened this issue Nov 1, 2017 · 0 comments
Closed

[SR-6270] Accessing _kvcKeyPathString #4494

swift-ci opened this issue Nov 1, 2017 · 0 comments

Comments

@swift-ci
Copy link
Contributor

@swift-ci swift-ci commented Nov 1, 2017

Previous ID SR-6270
Radar None
Original Reporter kzaher (JIRA User)
Type Improvement
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler, Foundation, Standard Library
Labels Improvement
Assignee None
Priority Medium

md5: 9c156f0c4bf4914f863ddc77c53f9ce9

duplicates:

  • SR-5220 Expose API to retrieve string representation of KeyPath

Issue Description:

Hi,

I've created a KVO wrapper in past that uses string based key path. Swift 4.0 introduces `KeyPath` class that provides a lot more type safety when working with key paths.

I can't seem to find any normal public API that exposes string keypath from KeyPath object.

The only API I could find is this `_kvcKeyPathString` weird looking property. It's underscored (so if I understand this correctly, even though it's public, it's intended for private use only) and doesn't contain any comments.
https://github.com/apple/swift/blob/main/stdlib/public/core/KeyPath.swift#L124

  • Is there some official public API that provides me with string keypath that is compatible with this objc API
    ````
  • (void)addObserver:(NSObject *)observer forKeyPath:(NSString *)keyPath options:(NSKeyValueObservingOptions)options context:(nullable void *)context;
    ```
  • Can I count on `_kvcKeyPathString` being backwards compatible when using Swift 4.x versions?

  • Is `_kvcKeyPathString` guaranteed to always return a value when working with objc classes only?

  • Is some new API being planned that exposes this functionality?

  • Why is the proper interpretation of `_`?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant