Assuming that your Core Data entity is a Book containing the attributes bookName, bookTitle & bookCategory.
@EnvironmentObject var firstTimeDisplayed: Bool
let bookList: FetchRequest<Book>
init() {
let bookRequest: NSFetchRequest<Book> = Book.fetchRequest()
bookRequest.sortDescriptors = [NSSortDescriptor(keyPath: \Book.title, ascending: true)]
if firstTimeDisplayed {
bookRequest.fetchLimit = 100
}
bookList = FetchRequest(fetchRequest: bookRequest)
}
...
// after determining that 100 books have been displayed for the first time
firstTimeDisplayed = false
I have split out the request so that fetchLimit is visible.
Also the firstTimeDisplayed parameter needs to keep its value even when the app is closed and restarted, so EnvironmentObject is a possible candidate.
The sorting is shown using a single keypath, and can be extended to use multiple keypaths - multiple sort keypaths
Depending on how quickly the initial 100 books are imported, you may need to keep a track of the number of book imported and then update the view from a holding view ('Setting up', 'Importing') to the display of the first 100 books.
I have not tried this out, so may need some tweaking. I hope that this helps you and gives you some ideas on how to proceed.