2

I have following Problem:

First up... i use MagicalRecord for the whole CoreData thing

  • I have two Entities: A and B
  • They have a relation between each other
  • I create one instance of Entity A
  • I create several instances ob Entity B and set the relation
  • I don't call [[NSManagedObjectContext defaultContext] save];
    • It's fine
    • The relation is ok... I can check it using the findByAttribute method
  • If I call this save then the relation is destroyed...
    • the same check using findByAttribute does not find results any more

I have absolutely no clue what I am doing wrong or if it's a bug in CoreData / MagicalRecord...

I made a sample project showing the problem. https://github.com/bliblablo/MagicalRecordsProblem

You can see the problem by following this steps:

  • click "create"
  • click "add"
  • click "check"
  • see the log output for results
  • click "save"
  • click "check" again and see the problem in the log :)

Any help is really appreciated!!! Thanks a lot!

Community
  • 1
  • 1
Georg
  • 3,664
  • 3
  • 34
  • 75
  • Where is the sample project? I can tell you with confidence that it won't be a bug in Core Data! – Nick Dowell Jul 03 '12 at 08:38
  • Sorry... I just updated my problem description. Here's the link: https://github.com/bliblablo/MagicalRecordsProblem – Georg Jul 03 '12 at 11:59

2 Answers2

4

Sounds like the problem I was having with temporary ObjectID's not getting refreshed in the default context.

See my answer on NSPredicate not executed for details.

If you haven't already sorted it out, try checking the ObjectID of the NSManagedObject instances at various points. Especially if you (or Magical Record) are using the object as part of an NSPredicate to do the later fetches.

Community
  • 1
  • 1
Otto
  • 18,761
  • 15
  • 56
  • 62
  • Thank you Otto... I worked around my problem by using a unique ID that I got from the webservice where the data comes from... So instead of calling "fetch everything where the parent is this object", I now use "fetch everything where the parent.uniqueID is this objects uniquID". This worked for me! But thanks for your explanation! Really appreciate it! – Georg Jul 12 '12 at 07:06
  • This is rather a workaround than a real solution, I guess. What really bothers me is that if you perform a "reset" before fetching the data, even using the 'fetch everything where the parent is this object' will work. So, definitely a Core Data (or MagicalRecord) bug. I'd love to try to completely wipe out this helper and to have fun the old-fashioned way. – Fabiano Francesconi Jul 12 '12 at 12:03
  • @FabianoFrancesconi I'm sure it's not a Magical Record but. I'm reasonably sure it is actually a bug in Core Data. I may still be misunderstanding what I'm supposed to be doing (listening for notifications, maybe?) but this works well enough. :) – Otto Jul 12 '12 at 22:34
  • Isn't it weird that only me and you have this kind of troubles? I mean, this is rather flashy bug. I think we are stucked in some sort of malpractice here.. I'm worried because the application seems to work now but it may happens that later in the future it may suddenly stop and we would have to go back and reconsider what we did. – Fabiano Francesconi Jul 13 '12 at 08:25
  • There's at least 3 of us. :) I am slightly worried, but I debugged it the first time, I can do it again. I plan to make sure I'm on the latest Magical Record before shipping, just to be sure. – Otto Jul 13 '12 at 21:10
  • Best I can figure, maybe we're not giving Core Data enough credit and it would lazy load the whole NSSet that comes back from the association method. But then I still don't have an NSFetchedResultsController. – Otto Jul 13 '12 at 21:10
0

I think this is not MR bug. It is a bug from core data. See this post. http://wbyoung.tumblr.com/post/27851725562/core-data-growing-pains

angelokh
  • 9,426
  • 9
  • 69
  • 139