enum Options: Int { case nuts case cherry case fudge } } 1 @OptionSet がマクロ – @ から始まるので見た目は Property Wrapper と同じ – コードの引用元: 1. The Swift Programming Language (5.9 beta)/Macros
class Trip { @Attribute(.unique) var name: String // Attached Macros var destination: String @Relationship(.cascade) // Attached Macros var bucketList: [BucketListItem]? = [] @Relationship(.cascade) // Attached Macros var livingAccommodation: LivingAccommodation? } 1 コードの引用元: 1. Model your schema with SwiftData
Trip", destination: "New York" ) // Insert a new trip context.insert(myTrip) // Delete an existing trip context.delete(myTrip) // Manually save changes to the context try context.save() 1 コードの引用元: 1. Meet SwiftData