views:

629

answers:

5

Hello everyone.

I have developed an iPhone app which stores photos in the /Documents directory of my app.

I would like to add a feature which gives to the user the opportunity to transfer those pictures to his/her PC or Mac.

I don't really know how to do that. What is the best way, using Bonjour, bluetooth, or directly USB (if it is possible) ? I really need some advices on that point ...

Any ideas ?

PS: Forgive my English, I am French :-)

+1  A: 

Bonjour!

I mean that both as a greeting and an answer. You have to setup a bonjour connection over wifi to transfer files directly to and from an app. That's actually pretty simple to do on both the iPhone and Mac side. The PC is a little tougher.

You can do bluetooth but bluetooth capability is still fairly rare on desktops.

TechZen
Bonjour only advertises the availability of services across the network. It doesn't provide file transfer capabilities.
Joshua Nozzi
Well, yes but that is where you start and that was the one of the options he asked about. Besides, I couldn't resist the pun.
TechZen
+2  A: 

Try NSNetService to register the service in Bonjour, and NSFileHandle to send data over a socket connection associated with the service.

Graham Lee
Thank you for your answer, I am working on that direction. But just a question, for that my iPhone and mac must be on the same network and I don't have wifi in my student room !! Does Bonjour service are discover if I create an ad-hoc network on my mac and connect my iPhone to that network ? And how can I look for Bonjour service on my mac ?? Cheers
@user251552: I don't remember - but there's a good way to find out :)
Graham Lee
Ok, I publish a Bonjour service, it works fine, I can see it in BonjourBrowser.app. Other question, do I need to write a program for my mac to sync my data ?? I am a little confused.
@user251552: yes, you'd need an app on the desktop side.
Graham Lee
+3  A: 

If you do not want to write a Mac or PC part for your app then you can also consider to build in a little http server that people can use to access the data in your app. There are some nice open source http servers available for Cocoa which you can find with Google.

Using Bonjour you can advertise your http server so that people can easily find it with a Bonjour enabled browser like Safari. (Your iPhone app's web server will appear automatically under the dynamic bonjour bookmarks items)

St3fan
Ok i will go on that direction. It seems to be a good way.Thanks to all guys for your precious help !!
+1  A: 

You've edited the question to say that it's about transferring photos. Could you store the photos on the iPhone's photo roll with UIImageWriteToSavedPhotosAlbum(), and let Apple handle getting them onto the computer?

Graham Lee
Thank you I even did not think about it ! It is the lazy way but it's actually exactly what I needed.Thanks to everyone, good continuation
A: 

Without knowing more about your specific application, I agree with Graham Lee--either directly saving to the Camera Roll or giving the user an option to save one or more photos to the Camera Roll is much simpler than http/bonjour.

chrispix