Saturday, November 7, 2026
HomeiOS Developmentios - CoreData - Invalid SQL (should specify a restrict with an...

ios – CoreData – Invalid SQL (should specify a restrict with an offset)

[ad_1]

I wish to get the variety of gadgets that I’ll get if a fetch request is executed. I exploit the countFor of the NSManagedObject. For depend and offset, there are non-negative values and in addition depend is larger than 0. When the code is executed, app crashes with this in console.

[error] error: SQLCore dispatchRequest: exception dealing with request: <NSSQLCountRequestContext: 0x600002990c40> , Invalid SQL (should specify a restrict with an offset) with userInfo of (null)
CoreData: error: SQLCore dispatchRequest: exception dealing with request: <NSSQLCountRequestContext: 0x600002990c40> , Invalid SQL (should specify a restrict with an offset) with userInfo of (null)
2022-01-05 18:16:43.413899+0530 colegia[11406:83454] *** Terminating app attributable to uncaught exception ‘NSInvalidArgumentException’, purpose: ‘Invalid SQL (should specify a restrict with an offset)’

Code:

 context.performAndWait {

        let request: NSFetchRequest = NSFetchRequest<NSManagedObject>.init(entityName: "ENTITY_NAME")

        
        request.fetchLimit = depend
        
        request.fetchOffset = offset
           
        request.includesPropertyValues = false
                                
        do {
            announcementsCount = attempt context.depend(for: request)
        }catch let error as NSError {
            print("Couldn't fetch. (error), (error.userInfo)")
        }
 }

What am I lacking right here ?

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments