4

I'm planning a way to persist data for an iOS (swift) app. From reading a bunch of articles about persistance on iOS, it seems Core Data is a really well supported way to do that. A bunch of libraries/tools are built around it, one popular combination seems to be MoGenerator + MagicalRecord + Core Data.

As MagicalRecord provides some kind of Active Record functionality, it seems it could be "easy" to accidentally break things. I've been told it could happen that users would have to reinstall their app to recover from such failures.

So question: is it feasible to use just plain Core Data instead of MoGenerator + MagicalRecord + Core Data? Or is this so low level, that it only makes to use raw Core Data for big teams? Can the pros/cons be compared to those of plain SQL vs ORM?

Philip
  • 3,470
  • 7
  • 29
  • 42
  • 1
    There was a time before MR & mo where everyone had to use plain CD, the additional tools are a convenience but that is all. – Wain Jan 20 '15 at 13:23
  • Agree with Wain, Magical Record removes a lot of boiler plate code and its really great but it won't solve any problems for you. I use it personally in small projects – Daniel Galasko Jan 20 '15 at 13:26
  • Btw, you can also use Core Data with MoGenerator w/o MR. – Martin R Jan 20 '15 at 13:29
  • 2
    Go with the plain Core Data! Build yourself a nice "core data engine" and build on top of it! The beginning is a bit hard until you understand all the stuff that's going on, but it's well worth it! – Razvan Jan 20 '15 at 13:29
  • Cool thanks! (Looks very much like answers ;)) – Philip Jan 20 '15 at 13:38
  • @codeFi so it's probably needed to do the usual clean up stuff and putting query results nicely into variables right? – Philip Jan 20 '15 at 13:39
  • @Philip when I said to create an "engine" I was referring to a master class, that contains and initializes the Core Data stack with different running mechanisms like multiple contexts, multiple stores, multithreaded (private contexts) and so on. Stuff like that :) - a class that you can later reuse with ease in other projects. – Razvan Jan 20 '15 at 13:43
  • Magical Record just saves you time when you deal Core Data. But it doesn't change anything. You are still using Core Data and you have to understand how it works first in order to use Magical Record effectively. I suggest another option. Use Realm. – mustafa Jan 20 '15 at 15:01

1 Answers1

13

I would strongly recommend to NOT use MR or Mogenerator until you know enough about Core Data to know WHY to use them.

Magical Record really can seem like magic if you don't understand what it is doing under the hood. And to use Core Data without a good understanding of the basic framework is to invite problems that you will never get to the bottom of. There are Core Data traps that you are going to need to understand, whatever tool you use.

CD is not really low-level compared with MR: but is more verbose (MR is saving you a lot of boilerplate). However I would recommend spending a bit of time with a decent book like Learning Core Data for iOS by Tim Roadley. When you have worked through that, you may find - as codeFi suggests - that you have built yourself a core data engine that does enough for you so that the addition of Magical Record unnecessary.

Another problem with going for MR is that the stable release, 2.2, is two years old. V2.3 is still in beta, and going forwards the focus is on 3.0. If you use the stable release, and find issues with it, they won't get fixed. If/when v3.0 is ready, the interface may be completely different anyway.

foundry
  • 31,615
  • 9
  • 90
  • 125