Skip to content

iCloudStorage is a property wrapper around NSUbiquitousKeyValueStore to easily access your shared UserDefaults.

License

Notifications You must be signed in to change notification settings

0xWDG/iCloudStorage

Repository files navigation

iCloudStorage

iCloudStorage is a property wrapper around NSUbiquitousKeyValueStore to easily access your shared UserDefaults.

Swift Package Manager License

Requirements

  • Swift 5.9+ (Xcode 15+)
  • iOS 13+, macOS 10.15+

Installation (Pakage.swift)

dependencies: [
    .package(url: "https://github.com/0xWDG/iCloudStorage.git", branch: "main"),
],
targets: [
    .target(name: "MyTarget", dependencies: [
        .product(name: "iCloudStorage", package: "iCloudStorage"),
    ]),
]

Installation (Xcode)

  1. In Xcode, open your project and navigate to FileSwift PackagesAdd Package Dependency...
  2. Paste the repository URL (https://github.com/0xWDG/iCloudStorage) and click Next.
  3. Click Finish.

Usage

import SwiftUI
import iCloudStorage

struct ContentView: View {
    @iCloudStorage("key")
    var value: String = "default"

    var body: some View {
        VStack {
            Text(value)

            Button("Change value") {
                value = "Hello there at \(Date())"
            }
        }
        .task {
            value = "Hello there"
        }
        .padding()
    }
}

Contact

🦋 @0xWDG 🐘 mastodon.social/@0xWDG 🐦 @0xWDG 🧵 @0xWDG 🌐 wesleydegroot.nl 🤖 Discord

Interested learning more about Swift? Check out my blog.

About

iCloudStorage is a property wrapper around NSUbiquitousKeyValueStore to easily access your shared UserDefaults.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Languages