tags:

views:

8046

answers:

6

I'm working on an iPhone application that would allow viewing and editing of data that I want to keep in sync with a desktop application. I don't see anything in the SDK that directly addresses data synchronization, nor can I find anything that allows my to "hook" into the iTunes sync process.

I could do something kludgy like hiding the data in a photo or address book entry, but that just seems like a bad idea. I could use WebDAV or HTTP to get/put data to a server, but it makes the application more complicated.

I guess I was expecting this to be a common use-case for iPhone apps (syncing arbitrary application data between a desktop and the iPhone) and that there would be a set of APIs in the SDK that cover this. Maybe there is and I just can't find it.

+4  A: 

I haven't tried this out myself, but I think Bonjour provides the ability to connect with services on other machines, you might find some answers looking into that

Robert Gould
+1  A: 

I'm also working on an application that needs to share data, the only reasonable/non hack way I found to get information in and out of the iPhone is through NSURLConnection.

(personal opinion) I don't foresee Apple providing hooks to the sync process.(/personal opinion)

lajos
+3  A: 

It's a common problem, but unfortunately not addressed by the SDK.

Since the iPhone supports Bonjour service publishing and discovery, you can easily publish a service on the phone and listen for it on the desktop, connecting when they find each other. (Or you can publish the service on the desktop and connect from the phone, either way it doesn't matter.) All of the documentation on Bonjour for MacO OS X applies to iPhone OS.

Note that Bonjour just advertises a service; once you find it, you still have to use sockets to connect and transfer data.

Basically, there is no easy way to do it, but there are enough tools available that you can make the sync experience painless for the user.

benzado
+4  A: 

The two popular methods are:

Sync with a desktop app directly via WiFi (using Bonjour etc. to discover the iPhone/desktop app endpoints as others have suggested here).

The other option is to sync with a shared file location - either FTP, MobileMe, WebDAV, web services on another server, etc. So the iPhone and desktop app would read/write to the shared location so the other can see the updates.

As others have said, there is no Apple provided method (using iTunes or otherwise) at this point and no indication that anything along those lines will be happening in the near future unless it's bundled with the iPhone's future support for third-party push updates. (I really doubt this will be the case, but you never know.)

Adam Byram
+5  A: 

Have a look at :

http://sourceforge.net/projects/syncdocs/

Looks good. I was hoping someone would come out with something like that, instead of reinventing the wheel for each app that comes out.
neonski
+2  A: 

An example for Bonjour Sync: http://cocoa-nut.de/?p=27