1

I know similar questions have been asked before. I'm using the Sync Demo app I found online here, which uses Picture Sharing as a guide.

I've integrated it into my desktop and iphone apps and have the connection working, but am clueless as to how to actually sync my objects.

Is it as simple as

if ([iphone Object] != [desktop object])
{
 //What goes here?
}

I have the exact same object model used, I just basically want to know how to check if there are differences, and copy the ones that are different over.

Anyone know of any sample code anywhere that would show this?

Thanks so much.

monotreme
  • 582
  • 1
  • 6
  • 20

2 Answers2

2

Have you tried out Marcus Zarra's ZSync? It's an open source implementation of Core Data syncing between Mac, iPhone, etc. using Bonjour.

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
  • It doesn't look like this has been updated in a while. The samples used to work under SDK 3, but I've yet to get them working in SDK 4, so I'm back to square one. – monotreme Dec 06 '10 at 13:04
  • @monotreme - I'm not sure what you're talking about. The Github project shows activity within the last couple of months, and the sample application that I just downloaded from the repository compiled and ran fine in the 4.2 Simulator for me just now. – Brad Larson Dec 06 '10 at 15:25
  • Huh, I just ran it yesterday and it registers fine, but when I go to sync or deregister my device it always crashes. What could I be doing wrong? – monotreme Dec 06 '10 at 22:27
  • @monotreme - I guess I didn't run it all the way through to sync with a device. What does the stack trace look like on the crash? Does the console show an exception being thrown? – Brad Larson Dec 06 '10 at 22:42
  • @BradLarson the link is expired no more working any alternate link for this? – Leena Nov 26 '12 at 06:35
  • @Leena - I've updated to point to Marcus' GitHub repository for the project. – Brad Larson Nov 26 '12 at 15:55
  • 1
    The project is deprecated and left up for historical purposes. I would not recommend using it as a cut-and-paste solution/framework but more as a guide on how to build your own. – Marcus S. Zarra Nov 26 '12 at 15:58
0

You could solve this with a timestamp column (e.g. - revisionTimestamp) that could be used to as a simple comparison and allow you to identify the most recent update.

Just make sure that your save logic updates the column automatically whenever an update is done.

xyzzycoder
  • 1,831
  • 13
  • 19
  • Thanks for the input. I figured I'd have to use a timeStamp to resolve when each was edited. What I'm asking is, how to I actually copy an object from the iphone to the desktop or vice-versa in code? – monotreme Mar 19 '10 at 07:00