What is the best way to synchronize kernel data with server-side data?

I have what I assume is a very common situation, but since I am new to iOS programming, I am not sure about the best way to encode it.

Description:

I have data on the server that can be obtained by the iPhone application through the REST service. On the server side, the data are objects with a foreign key (integer identification number).

I store data retrieved using REST in Core Data. Managed objects have the objId attribute so that I can uniquely identify managed objects in the rest of my code.

My application should always display server data.

On subsequent requests made by the server:

  • some objects cannot be returned, they were deleted on the server - in this case I need to delete the corresponding objects from Core Data - so that I correctly reflect the status of the server.

  • some objects have changed attributes, so the corresponding managed objects need to be updated with new data.

my decision is a question for you

To keep everything in my application, I made the easiest solution to delete all objects in Core Data, and then added all new objects created using the latest server-side data.

I do not think this is the best way to approach him. When I go along with my application, now I want to link my table with NSFetchedResultsController and realized that my approach to deleting everything and re-adding will no longer work.

Core Data ?

, , ?

, , ?

? , Core Data, .

:)

!

+3
1

, . -, ( , SO, , ).

, , , , , , . , " " "" ( ).

, -, , , " " . , , fetchLimit 1 . "id " INDEX . , , , , . .

. . , .

, , . , , . . - , , , " ".

- . , - . , " " ( ). , - , , , , .

+3

All Articles