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
732
Jul ’23
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.
Replies
0
Boosts
1
Views
732
Activity
Jul ’23
Xcode 12.5.1 (12E507) Unable to add GPS Exchange to project
GPX exchange no longer works. When selecting a gpx file, all gpx files are greyed out. This was working fine before, and in fact my project has a gpx file it was using to simulate gps and this was working and now no longer is listed as a location to simulate. This is hampering my development.
Replies
6
Boosts
2
Views
4.2k
Activity
Sep ’22