I have a little test app that is using "native" CoreData (iOS 5.1). I was about to set out to create a wrapper around CoreData to simplify my coding when I stumbled upon the MagicalRecord wrapper for CoreData (https://github.com/magicalpanda/MagicalRecord) and really liked the approach that was taken.
I converted my test app to use MagicalRecord. This was very easy to do and worked very well. The only issue I am having is in how MagicalRecord uses a background saving queue to keep db activity off of the main thread.
The app is a very basic single-threaded parent child relationship using a navigation controller and some table view controllers. When I create a new parent, and then add a child record, the child record is not showing up in the child table view. This appears to be due to how MagicalRecord handles temporary ObjectIds such that the fetch is unable to find the new children since the parent's object id is not yet a permanent object id. I may not have this exactly right, but I believe that is the general issue.
I have read a number of posts, mostly on stack overflow and a number of people mention the same issue, but I am not sure of the solutions posted. Most seem to point to an actual issue within CoreData and how nested contexts do not always notify the parent context of changes (or something like that). The solutions people post seem to deal with multi-threaded scenarios while my test app is a much more basic single-threaded app. If I shut down the app and restart it, the objects then all have permanent ids and they all appear in the table views as expected. I believe I could use the MagicalRecord "reset" method to "fix" my issue, but that doesn't feel right to me.
I am tempted to revert back to using "native" CoreData without the wrapper, but it really is a nice library and I feel I am just missing something here.
The library also looks like it will serve very well for when I create a more involved multi-threaded app. It has some really nice background thread support.
Has anyone else used this library and had the same issue pop up?
Thanks for your time!
Michael
I converted my test app to use MagicalRecord. This was very easy to do and worked very well. The only issue I am having is in how MagicalRecord uses a background saving queue to keep db activity off of the main thread.
The app is a very basic single-threaded parent child relationship using a navigation controller and some table view controllers. When I create a new parent, and then add a child record, the child record is not showing up in the child table view. This appears to be due to how MagicalRecord handles temporary ObjectIds such that the fetch is unable to find the new children since the parent's object id is not yet a permanent object id. I may not have this exactly right, but I believe that is the general issue.
I have read a number of posts, mostly on stack overflow and a number of people mention the same issue, but I am not sure of the solutions posted. Most seem to point to an actual issue within CoreData and how nested contexts do not always notify the parent context of changes (or something like that). The solutions people post seem to deal with multi-threaded scenarios while my test app is a much more basic single-threaded app. If I shut down the app and restart it, the objects then all have permanent ids and they all appear in the table views as expected. I believe I could use the MagicalRecord "reset" method to "fix" my issue, but that doesn't feel right to me.
I am tempted to revert back to using "native" CoreData without the wrapper, but it really is a nice library and I feel I am just missing something here.
The library also looks like it will serve very well for when I create a more involved multi-threaded app. It has some really nice background thread support.
Has anyone else used this library and had the same issue pop up?
Thanks for your time!
Michael