Swiftpack.co -  Package - quangnghiadev/SafeDictionary
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
quangnghiadev/SafeDictionary
SafeDictionary for safe access dictionary value when working with multi thread
.package(url: "https://github.com/quangnghiadev/SafeDictionary.git", from: "1.0.0")

Build Status SPM compatible Swift Xcode MIT

SafeDictionary

SafeDictionary for safe access dictionary value when working with multi thread

Installation

Swift Package Manager

You can use The Swift Package Manager to install AsyncOperation by adding https://github.com/quangnghiadev/SafeDictionary.git to Swift Package of your XCode project

Usage

Using this class for safe access dictionary value when working with multi thread

let safeDictionary = SafeDictionary<String, Int>(queueLabel: "queue.name")

/// Get value from key
let id = safeDictionary["id"]
// or
let id = safeDictionary.getValue(key: "id")

/// Update value for key
safeDictionary.updateValue(2, forKey: "id")
// or
safeDictionary["id"] = 2

/// Remove value with key
safeDictionary.removeValue(forKey: "id")

/// Get all keys
let keys = safeDictionary.keys

/// Remove all element with keeping capacity ability
safeDictionary.removeAll()
safeDictionary.removeAll(keepingCapacity: true)

License

  • Safe Dictionary is released under the MIT license. See LICENSE for more information.

GitHub

link
Stars: 0
Last commit: 1 week ago

Release Notes

Alpha
23 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco