Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vinhnx/dictionarynestedsubscript
Nested subscript for Dictionary.
https://github.com/vinhnx/dictionarynestedsubscript
demo github-package-registry smile swift swift-package-manager swiftpm xcode
Last synced: 13 days ago
JSON representation
Nested subscript for Dictionary.
- Host: GitHub
- URL: https://github.com/vinhnx/dictionarynestedsubscript
- Owner: vinhnx
- License: mit
- Created: 2019-06-11T05:43:12.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-17T13:45:49.000Z (over 4 years ago)
- Last Synced: 2024-09-16T03:48:02.807Z (about 2 months ago)
- Topics: demo, github-package-registry, smile, swift, swift-package-manager, swiftpm, xcode
- Language: Swift
- Homepage:
- Size: 110 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DictionaryNestedSubscript
A Swift Package that enable nested `subscript` on `Dictionary`.
### Usage
```swift
import DictionaryNestedSubscriptlet dictionary: [String: Any] = [
"countries": [
"japan": [
"capital": [
"name": "tokyo",
"lat": "35.6895",
"lon": "139.6917"
],
"language": "japanese"
]
]
]dictionary[jsonDict: "countries"]?[jsonDict: "japan"]?[jsonDict: "capital"]?["name"] // "tokyo"
```### Integration (requires Xcode 11+)
1. from your project, Choose `Xcode > File > Swift Packages > Add Package Dependency...`
![demo](./screenshot/step_1.png)
2. put `https://github.com/vinhnx/DictionaryNestedSubscript` under `Choose Package Repository` field
![demo](./screenshot/step_2.png)
3. (optional) specify the version or branch or specific commit you want to use from the package
![demo](./screenshot/step_3.png)
4. then click `Next` for Xcode to resolve the package.
![demo](./screenshot/step_4.png)
5. Choose where to add Package framework to your app's target
![demo](./screenshot/step_5.png)
6. Profit :smile:
![demo](./screenshot/step_6.png)
### References
Guide
+ https://developer.apple.com/documentation/swift_packages/creating_a_swift_package_with_xcode
+ https://developer.apple.com/documentation/swift_packages/publishing_a_swift_package_with_xcodeInspiration
+ https://github.com/krzyzanowskim/CollectionSafeIndex (for the idea :smile:)
+ https://stackoverflow.com/a/41543070/1477298 (for the logic :rocket:)