Loading...
Loading...
Writes, reviews, and improves SwiftData code using modern APIs and best practices. Use when reading, writing, or reviewing projects that use SwiftData.
npx skill4agent add twostraws/swiftdata-agent-skill swiftdata-proreferences/core-rules.mdreferences/predicates.mdreferences/cloudkit.mdreferences/indexing.mdreferences/class-inheritance.md// Before
var sights: [Sight]
// After
@Relationship(deleteRule: .cascade, inverse: \Sight.destination) var sights: [Sight]isEmpty == false!// Before
#Predicate<Destination> { $0.sights.isEmpty == false }
// After
#Predicate<Destination> { !$0.sights.isEmpty }@Query// Before
class DestinationStore {
@Query var destinations: [Destination]
}
// After
class DestinationStore {
var modelContext: ModelContext
func fetchDestinations() throws -> [Destination] {
try modelContext.fetch(FetchDescriptor<Destination>())
}
}isEmpty == false!isEmpty@Queryreferences/core-rules.mdreferences/predicates.mdreferences/cloudkit.mdreferences/indexing.mdreferences/class-inheritance.md