Using GameKit to Transfer CoreData Data Between iPhone

I have an application in which I would like to exchange information managed through Core Data between two iPhones.

Has anyone tried to do this, and if so, then this is the best way to do this (for example, people use some intermediate format such as XML or JSON in a file or can pass objects directly).

My apologies if the question appears too rude, but I am at the stage where I need to make a decision about the transfer, and I have no experience using this API.

I would be extremely grateful for any code samples or links to any such code for transferring objects between devices using GameKit.

+3
source share
2 answers

You cannot transfer Core Data objects directly between devices because they are related to their context and persistent storage. You will need to convert the data to an intermediate format (it can be as simple as NSDictionary, which turns into NSData) and click on the connection and then restore the data from the other side.

Personally, I feel that JSON is great for this type of situation, because you can easily turn a Core Data object graph into a collection of JSON consumable objects (dictionaries, arrays, strings, and numbers) that can be easily moved.

+5
source

? , iPhone (?).

, , , " " " : API Apple Mac OS X".

http://www.pragprog.com/titles/mzcd/core-data

GameKit Bluetooth. IP , AsyncSockets.

http://code.google.com/p/cocoaasyncsocket/

+2

Source: https://habr.com/ru/post/1734866/


All Articles