Relative Content

Tag Archive for iosswiftswiftdata

How to filter a swiftdata query with multiple conditions?

static func GetCardsToLearnPredicate() -> Predicate<Card> { let todayMinus3Days: Date = Date.now.addDay(day: -3) let todayMinus7Days: Date = Date.now.addDay(day: -7) let todayMinus14Days: Date = Date.now.addDay(day: -14) let todayMinus30Days: Date = Date.now.addDay(day: -30) return #Predicate<Card> {card in card.box == 1 || (card.box == 2 && card.lastStatusChange >= todayMinus3Days) || (card.box == 3 && card.lastStatusChange >= todayMinus7Days) || (card.box […]

How to filter a swiftdata query with multiple conditions?

static func GetCardsToLearnPredicate() -> Predicate<Card> { let todayMinus3Days: Date = Date.now.addDay(day: -3) let todayMinus7Days: Date = Date.now.addDay(day: -7) let todayMinus14Days: Date = Date.now.addDay(day: -14) let todayMinus30Days: Date = Date.now.addDay(day: -30) return #Predicate<Card> {card in card.box == 1 || (card.box == 2 && card.lastStatusChange >= todayMinus3Days) || (card.box == 3 && card.lastStatusChange >= todayMinus7Days) || (card.box […]

String representation of SwiftData PersitentIdentifiers

Use case: I would like to associate subfolders stored in the Application Support Directory on iOS with already saved instances of a SwiftData entity type. If I had a way to represent the primary keys of the entities as a string, I could simply name these subfolders after the primary keys (without the need to generate e.g. random UUID folder names and persist these UUIDs as a field in the entity).