Vikram Singh
Vikram Singh

Reputation: 33

I have some confusion in core data?

I am new in core data please help me in some confusions...

  1. If core data use sqlite in back end then why we use core data not sqlite??

  2. How it is faster then sqlite.

  3. I read a difference that In core data when we want to edit anything it loads all data in memory..but if it loads then why app. not getting slow or crash.

  4. How to show data of a (.sqlite) file that store in Document Directory.

  5. core data is use for persistence storage but it's not a data base(Explain me)???.

Please define all things to me...

Thanks in advance.

Upvotes: 0

Views: 325

Answers (3)

Ramesh Lingappa
Ramesh Lingappa

Reputation: 2488

  1. If core data use sqlite in back end then why we use core data not sqlite??

Core data doesn't always use SQLite , SQLite is one type of store option( most widely used ), there are two other types available as well Check this coredata store types

  1. How it is faster then sqlite.

Core data is not an replacement to SQLite , it is like an ORM for SQLite , it handle all heavy work and provide easier interface to work with SQLite , it handles store connection , querying storing , managing and tracking in memory changes etc

  1. I read a difference that In core data when we want to edit anything it loads all data in memory..but if it loads then why app. not getting slow or crash.

This is wrong , core data does not load everything in memory unless you query it yay ways , in general when you fetch an entity it returns NSManagedObject instance to work with that entity

  1. How to show data of a (.sqlite) file that store in Document Directory.

What do you mean by show data in SQLite file , u will query what data you want using NSPredicate and get an array of objects as response

The .sqlite database will be stored within app sandbox folder Check this sqlite storage

  1. core data is use for persistence storage but it's not a data base(Explain me)???.

Coredata is not an persistence storage it's persistence store manager, as I said above it handles all heavy lifting work like creating connection , executing query , converting result to NSManagedObject , tracking object changes , persisting it to SQLite and managing entire object graph you loaded into memory

Upvotes: 2

Rukshan
Rukshan

Reputation: 8066

It's hard to compare core-data with sqlite because these are two different technologies. However here are few things you won't get from sqlite out of the box.

  1. Built-in change tracking and undo support. Core Data provides built-in management of undo and redo beyond basic text editing.

  2. Easy iCloud storage integration (with NSManagedDocument)

  3. Optional integration with the application’s controller layer to support user interface synchronization. Eg:- Core Data provides the NSFetchedResultsController object on iOS

  4. Full, automatic, support for key-value coding and key-value observing.

  5. Instead of writing SQL, you can create complex queries by associating an NSPredicate object with a fetch request. NSPredicate provides support for basic functions, correlated subqueries, and other advanced SQL. With Core Data, it also supports proper Unicode, locale-aware searching, sorting, and regular expressions.

  6. Merge policies. Core Data provides built in version tracking and optimistic locking to support automatic multi-writer conflict resolution.

  7. Core Data can reduce the memory overhead of your program by lazily loading objects. It also supports partially materialized futures, and copy-on-write data sharing.

Upvotes: 1

Rajan Maheshwari
Rajan Maheshwari

Reputation: 14571

Core Data is the best option to use but if somehow you want to port the application to android or windows and want to keep the code similar then you can go for SQLITE as SQLite is supported by all major platforms. Whereas core data is only part of iOS. Regarding various doubts you can refer this link

Use Core Data or not?

Upvotes: 0

Related Questions