Skip to main content

How to find a SwiftData object by its identifier

Less than 1 minuteSwiftArticle(s)bloghackingwithswift.comcrashcourseswiftswiftdataxcodeappstore

How to find a SwiftData object by its identifier 관련

SwiftData by Example

Back to Home

How to find a SwiftData object by its identifier | SwiftData by Example

How to find a SwiftData object by its identifier

Updated for Xcode 15

Rather annoyingly this will cause a crash if your persistent identifier is invalid, so I prefer to use the registeredModel(for:) variant that only returns an object if it exists in the current model context. (Of course, that has its own problems because your model context likely only contains a subset of all the objects in your container!)


이찬희 (MarkiiimarK)
Never Stop Learning.