mergeChangesFromContextDidSaveNotification crash #63

Closed
opened 2025-12-29 15:23:20 +01:00 by adam · 3 comments
Owner

Originally created by @tomasgibas on GitHub (May 26, 2016).

CoreStore.beginAsynchronous { (transaction) in
            let bookIds = Array(booksWithRating.keys).map { NumberFormatter.numberFromString($0)!.integerValue }
            let books = transaction.fetchAll(From(Book), Where(kBookWithIDsPredicate, bookIds))
            books?.forEach({ (book) in
                transaction.delete(book.rating)
                let rating = transaction.create(Into(Rating))
                rating.date = NSDate()
                rating.rating = Float(booksWithRating[String(format: "%@", book.bookId!)]!)
                book.rating = rating
            })
            transaction.commit()
        }

Most of the time, when it comes to commit, an exception will raise in NSManagedObjectContext+Setup.swift, line 97. Am I doing something wrong? I am not sure what.

Originally created by @tomasgibas on GitHub (May 26, 2016). ``` swift CoreStore.beginAsynchronous { (transaction) in let bookIds = Array(booksWithRating.keys).map { NumberFormatter.numberFromString($0)!.integerValue } let books = transaction.fetchAll(From(Book), Where(kBookWithIDsPredicate, bookIds)) books?.forEach({ (book) in transaction.delete(book.rating) let rating = transaction.create(Into(Rating)) rating.date = NSDate() rating.rating = Float(booksWithRating[String(format: "%@", book.bookId!)]!) book.rating = rating }) transaction.commit() } ``` Most of the time, when it comes to commit, an exception will raise in NSManagedObjectContext+Setup.swift, line 97. Am I doing something wrong? I am not sure what.
adam added the user bug label 2025-12-29 15:23:20 +01:00
adam closed this issue 2025-12-29 15:23:21 +01:00
Author
Owner

@JohnEstropia commented on GitHub (May 26, 2016):

What does the exception message say?

@JohnEstropia commented on GitHub (May 26, 2016): What does the exception message say?
Author
Owner

@tomasgibas commented on GitHub (May 26, 2016):

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Rating compare:]: unrecognized selector sent to instance 0x12823c5a0'

@tomasgibas commented on GitHub (May 26, 2016): Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Rating compare:]: unrecognized selector sent to instance 0x12823c5a0'
Author
Owner

@JohnEstropia commented on GitHub (May 27, 2016):

Somewhere in one of your observers, you are using a Rating instance incorrectly. Your hint is there:

 '-[Rating compare:]: unrecognized selector sent to instance

Add an exception breakpoint in Xcode and try to reproduce the crash. The breakpoint will stop at the real location of your problem.

This is not a CoreStore issue so I'm closing this ticket.

@JohnEstropia commented on GitHub (May 27, 2016): Somewhere in one of your observers, you are using a `Rating` instance incorrectly. Your hint is there: ``` '-[Rating compare:]: unrecognized selector sent to instance ``` [Add an exception breakpoint](https://developer.apple.com/library/ios/recipes/xcode_help-breakpoint_navigator/articles/adding_an_exception_breakpoint.html) in Xcode and try to reproduce the crash. The breakpoint will stop at the real location of your problem. This is not a CoreStore issue so I'm closing this ticket.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore#63