iOS - Data Management

iOS has a comprehensive collection of tools and frameworks for storing, accessing, and sharing data.

Core Data is a full-featured data modeling framework for object-oriented Cocoa Touch applications, while SQLite is perfect for low-level relational database work. Applications can share data using a URL-based system that works across all of iOS. Web apps can persist data in a client-side cache with the HTML5 data storage API. iPhone apps even have access to a device’s global data such as contacts in the Address Book, and photos in the Photo Library.

Core Data

Core Data

Core Data provides a flexible and powerful data model framework for building well-factored Cocoa applications based on the Model-View-Controller (MVC) pattern. Core Data provides a general-purpose data management solution developed to handle the data model needs of every kind of application, large or small. You can build anything from a contact-management application to a vector-art illustration program on top of it. The sky is the limit.

Core Data lets you quickly define your application’s data model in a graphical way and easily access it from your code. It provides an infrastructure to deal with common functionality such as save, restore, undo and redo, allowing you to get on with the task of building innovation into your application. Because Core Data uses the built-in SQLite data library there is no need to install a separate database system.

Interface Builder, Apple’s graphical user interface editor, provides pre-built Core Data controller objects that eliminate the need for much of the glue code between your application's user interface and its data model. You don’t have to worry about SQL syntax. You don’t have to maintain logic trees to track user behavior. You don’t have to create a new persistence mechanism. It’s all done for you, when you wire your application’s user interface to its Core Data model.

SQLite

iOS includes the popular SQLite library, a lightweight yet powerful relational database engine that is easily embedded into an application. Used in countless applications across many platforms, SQLite is considered a de facto industry standard for lightweight embedded SQL database programming. Unlike the object-oriented Core Data framework, SQLite uses a procedural, SQL-focused API to manipulate the data tables directly.

Access Contacts and
Photos

Data and media from iPhone are available to your application via safe, easy-to-use APIs. Your application can create new Address Book contacts and get existing contact info. Similarly, your app can load, display, and edit photos from the Photo Library, as well as use the built-in camera take new photos.

Share Data Among
Apps

iOS provides powerful connectivity options for sharing information among the applications installed on a device. Using a URL-based syntax, you can access data from the Web, as well as pass information to other installed applications, such as Mail, iTunes, and YouTube. Your own application can declare a unique URL scheme, allowing any application to collaborate and share data with your app.

XML Files

XML files provide a lightweight structured format that your application can easily read and write. Plus XML files readily fit into the iPhone file system. Store your application settings and user preferences in the built-in User Defaults database. This XML-based data store includes a simple API with powerful features, including the ability to serialize and restore complex objects on demand.

HTML5 Client-Side
Storage in Safari

The advanced Safari browser included in iOS supports the latest HTML5 offline data storage features. The offline storage means a web app can store session data locally in a cache on the iPhone or iPod touch device, using either a simple key/value data API, or a more advanced SQL interface. The data is persistent among Safari launches, meaning apps start up faster, are less dependent upon the network, and perform better than ever before.