Geek Alert!
My next app will need a sophisticated database. I had planned to use Apple’s Core Data framework which seemed perfect for the job, but since then I’ve learned that there’s a relatively new kid on the block, namely Realm.
Core Data’s competence is not in question, but I’ve read a fair bit on it and many comments around the net and one thing that people seem to agree on is that it’s not straightforward to implement.
Realm, on the other hand, is very simple to implement, building, as it does, on the structure of the main code in a fairly straightforward manner. For example, a Swift code fragment using Realm might look as follows:
// Create a Person object
let author = Person()
author.name = “David Foster Wallace”
// Get the default Realm
let realm = Realm()
// You only need to do this once (per thread)
// Add to the Realm inside a transaction
realm.write {
realm.add(author)
}
I don’t have the comparable Core Data code, but trust me when I say it would be a lot more complex. The Realm code is simple to understand, if you understand this sort of thing!
However, my app needs a lot more than just a database to make it all work so I’d better get on with that first. This new app will be my first app written using Swift, Apple’s brand new programming language and I’m really excited by that. I’ll keep you updated. 🙂