Skip to content

Instantly share code, notes, and snippets.

@jasdev
Created January 19, 2021 03:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasdev/e765d7410c432af94170b02630fa5039 to your computer and use it in GitHub Desktop.
Save jasdev/e765d7410c432af94170b02630fa5039 to your computer and use it in GitHub Desktop.
Identifiable conformance backed by a Self.self expression.
import Foundation
import SwiftUI
struct AlertData: Identifiable {
let id = String(describing: Self.self)
var message: String
}
struct ScratchView: View {
var body: some View {
Circle() // For sake of example.
.alert(item: .constant(AlertData(message: "Hi!"))) { alertData in
Alert(title: Text(alertData.message))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment