FTASync icon indicating copy to clipboard operation
FTASync copied to clipboard

EXC_BAD_ACCESS error when opening a record that is created

Open hugomelis opened this issue 12 years ago • 2 comments

In the example app I get the following EXC_BAD_ACCESS error when I have created a person. You can reproduce it by creating a new person after logging in. After that you directly try to edit this record by clicking on it. The error is produced because the record is not yet inserted (as far as I can tell). After restarting the app (and probably trigger something that actually saves the record) the person can be clicked and therefore edited. The method that triggers the EXC_BAD_ACCESS is: updateInterfaceForCurrentPerson

In the debugger a PO of self.person shows this: (Person *) $1 = 0x07a2ffa0 <Person: 0x7a2ffa0> (entity: CDPerson; id: 0x9055ee0 x-coredata://05BD5986-FA3C-4F0D-9025-4A34FB52291D/CDPerson/tE9FFF278-49AE-4C11-8BE6-B29EC909B1A02 ; data: )

After a restart a PO of self.person shows this: (Person *) $1 = 0x0f691360 <Person: 0xf691360> (entity: CDPerson; id: 0x7d9b8a0 x-coredata://05BD5986-FA3C-4F0D-9025-4A34FB52291D/CDPerson/p2 ; data: )

hugomelis avatar Nov 24 '12 12:11 hugomelis

I found the solution to this, the MagicalRecord supplied with the example is outdated. I updated the version with the current one and after changing 3 calls to method in FTASyncHandler.m: [[NSManagedObjectContext MR_contextForCurrentThread] MR_saveErrorHandler:^(NSError *error){ into: [[NSManagedObjectContext MR_contextForCurrentThread] MR_saveWithErrorCallback:^(NSError *error){ all was working correctly in the example!

hugomelis avatar Nov 24 '12 19:11 hugomelis

Glad you got it working! It looks like you were getting temporary object IDs, which was fixed in Magical Record here: magicalpanda/MagicalRecord@0b00e39b2692f34e1d9c2f00e96a801892e53f14

It looks like Magical Record recently removed the MR_saveErrorHandler: method (magicalpanda/MagicalRecord@f7c4350e9daf7d90eec83ba5eafeccfa7af34312) so FTASync needs updated to account for that.

itsniper avatar Nov 26 '12 20:11 itsniper