Post

Replies

Boosts

Views

Activity

Searching the database outside of the view
How do I perform a search using SwiftData within an observable data model For example: If I have a database of books that contains the property isbn, how would I perform a search to confirm I either had or did not have a book with the isbn I am searching for? Using CoreData I use a fetch request: let predicate = NSPredicate(format: "%K == %@", #keyPath(Book.isbn), isbn) let fetchRequest: NSFetchRequest<Book> = Book.fetchRequest() ... let book = try context.fetch(fetchRequest). // returns [book] use isEmpty for not found. ... if book.isEmpty { saveBook() } I have a number of queries I perform on the database to drive the logic within the app, this is just one example.
0
1
586
Jul ’23
What are Apple's plan for Transformable Custom class [Double]
For simplicity when storing arrays of Int, Double, or Date I placed [Int], or [Double], or [Date] in the Attribute custom class field (see screenshot), however when the app compiles the following error is shown: Misconfigured Property: Entity.timestamp is using a nil or insecure value transformer. Please switch to NSSecureUnarchiveFromDataTransformerName or a custom NSValueTransformer subclass of NSSecureUnarchiveFromDataTransformer Does this mean that Apple will be dropping this feature, i.e. the option of adding arrays this way will be removed, or if they update their code will the data in my database be unreadable? What is best practice of storing large data arrays in core data?
1
0
649
Jul ’21