Realm Mobile Database for iOS

Realm Mobile Database for iOS

In this tutorial, I'll show you how to use a powerful yet elegant on-device database solution for your iOS apps: Realm Mobile Database. An alternative to Apple Core Data or SQLite with object-relational mapping (ORM), Realm Mobile Database offers developers an easier and more natural way to store and query data.

What Is Realm Mobile Database?

Billed as a true object database, Realm differentiates itself from other similar libraries by treating data objects as live objects—meaning objects are automatically updated. They react responsively to changes and are easy to persist. Even better, you don’t have the steep learning curve that you would with Core Data or SQLite scripting. Instead, you can work in a truly object-oriented way. Realm Mobile Database has also been open-sourced as of 2016, and is available free of charge to developers.

In addition to Realm Mobile Database, the company also offers Realm Mobile Platform, its flagship PAAS to complement Realm Mobile Database with a server-side solution.

Realm Mobile Platform, extends that core with realtime data synchronization and event handling on the server side, all seamlessly connected to the apps. Developers use the platform to build apps with powerful functionality like messaging, collaboration, and offline-first capabilities. The platform is also ideal for mobilizing existing APIs, making it easy to build highly responsive and engaging apps connected to legacy systems and services. (realm.io)

So Realm Mobile Platform works on the server side in the same seamless way as Realm Mobile Database, providing automatic data synchronization and event handling between the client and server, and in the process abstracting away the complexities that arise when dealing with data synchronization. Realm Mobile Platform is beyond the scope of this tutorial, but I'll come back to it in a future post.

Why Realm Mobile Database?

Beyond saving developers the headache and steep learning curve of Core Data, Realm Mobile Database provides distinctive advantages right out of the box.

Performance & Thread-Safety

Performance-wise, Realm Mobile Database has been proven to run queries and sync objects significantly faster than Core Data, and accessing the data concurrently isn’t a problem. That is, multiple sources can access the same object without the need to manage locks or worry about data inconsistencies.

Encryption

Realm Mobile Database provides its own encryption services to protect databases on disk using AES-256+SHA2 through 64-byte encryption.

This makes it so that all of the data stored on disk is transparently encrypted and decrypted with AES-256 as needed, and verified with a SHA-2 HMAC. The same encryption key must be supplied every time you obtain a Realm instance.

Cross-Platform

Unlike Core Data, Realm Mobile Database is truly cross-platform, supporting iOS, Android, JavaScript web apps, and Xamarin.

Reactive Nature

Because of the way the live objects work, you are able to wire up your UI elements to the data models and your UI will update reactively as the data changes! There is no complicated synchronization code or wiring logic needed, as you would have with Core Data.

When coupled with Realm Mobile Platform and the Realm Object Server, developers will gain the extra benefit of syncing their data to the cloud by simply setting the Realm Object URL.

Even using Realm Mobile Platform, you don’t have to worry about interrupted connections, as Realm has built-in offline capabilities and will queue any data changes to be sent to the server.

Clients

Realm has numerous distinguished clients that have openly adopted Realm Mobile Database, including Netflix and Starbucks.

Alternatives to Realm Mobile Database

Of course, Realm Mobile Database is not the only app storage solution. I already mentioned Apple’s own Core Data, and while it is inherently more complicated to learn, the fact that it belongs to Apple means it will be the de facto database solution for many iOS developers, and will continue to have a large community of developers and support material.

A solution that is somewhat similar to Realm Mobile Database is Google’s Firebase—although this is a combined client-side and server-side solution. Firebase is similarly easy to use and it's free to get started with, but the costs will scale as your usage does. One drawback with Firebase is that you are tightly coupled to their platform, whereas with Realm you are free to use your own back-end—or no back-end at all!

Read the complete article, exclusively at TutsPlus


要查看或添加评论,请登录

Doron Katz的更多文章

  • TPM University Monthly Newsletter March 2025 Edition

    TPM University Monthly Newsletter March 2025 Edition

    Defrosting a bit as we enter March, the industry is still quite dynamic unfortunately. I am sending out positive vibes…

  • 2025 February TPM University Newsletter

    2025 February TPM University Newsletter

    Midwinter is here, second month in to 2025. And it’s been an interesting start to the year so far.

    1 条评论
  • 2025 January TPM University Newsletter

    2025 January TPM University Newsletter

    Welcome to 2025! I am excited to see where the TPM domain infused with GenAI will be taking us. And focusing my career…

  • A TPM’s Guide to System Scalability

    A TPM’s Guide to System Scalability

    In our next installment on A TPM’s Guide, we are going to dive into scalability. But let’s start off first with the…

  • TPM University Monthly Newsletter December Edition

    TPM University Monthly Newsletter December Edition

    We’ve finally made it to the last month of 2024. I’ve started ramping up my writing, aiming to do an article a month.

    3 条评论
  • November 2024 Edition

    November 2024 Edition

    Welcome to the month of November. I am excited to reboot my newsletter in a new monthly format.

    2 条评论
  • PMP 101: UNDERSTANDING THE DIFFERENT ORGANIZATIONAL STRUCTURES

    PMP 101: UNDERSTANDING THE DIFFERENT ORGANIZATIONAL STRUCTURES

    Read this and more by going to doronkatz.com Let’s dive deep into a prominent PMI-PMP area of study, Organizational…

  • ScaleWithAgile Newsletter #004

    ScaleWithAgile Newsletter #004

    In this week’ edition, we take a look at * Agile Metrics:What to Measure and Why… ?? Scrummaging Around the World Here…

  • ScaleWithAgile Newsletter #002

    ScaleWithAgile Newsletter #002

    In this week’ edition, we take a look at * Agile Metrics:What to Measure and Why… ?? Scrummaging Around the World Here…

  • ScaleWithAgile Newsletter #001

    ScaleWithAgile Newsletter #001

    In this week’ edition, we take a look at Agile Contracts, Crafting Agreements for Agile Projects. Scrummaging Around…

社区洞察

其他会员也浏览了