shareup / identifier-apple

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Identifier

Identifier represents a globally unique identifier. It is backed by a Base64URL-encoded string. Identifier is commonly used as a model identifier, and it can help one conform to Swift's Identifiable protocol.

Usage

struct Todo: Hashable, Identifiable {
    let id: Identifier
    let title: String
    let isCompleted: Bool
}

extension Todo {
    init(title: String) {
        id = Identifier() // New, unique identifier
        self.title = title
        isCompleted = false
    }
}

Installation

Swift Package Manager

To use Identifier with the Swift Package Manager, add a dependency to your Package.swift file:

let package = Package(
   dependencies: [
       .package(
           url: "https://github.com/shareup/identifier-apple.git", 
           from: "6.1.0"
       )
   ]
)

About

License:MIT License


Languages

Language:Swift 95.2%Language:Shell 4.8%