3

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 :-)

TechZen
  • 64,370
  • 15
  • 118
  • 145
rmonjo
  • 2,675
  • 5
  • 30
  • 37

5 Answers5

3

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

  • 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 – rmonjo Feb 21 '10 at 15:54
  • @user251552: I don't remember - but there's a good way to find out :) –  Feb 21 '10 at 15:57
  • 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. – rmonjo Feb 21 '10 at 16:50
  • @user251552: yes, you'd need an app on the desktop side. –  Feb 22 '10 at 18:01
3

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)

Stefan Arentz
  • 34,311
  • 8
  • 67
  • 88
  • Ok i will go on that direction. It seems to be a good way. Thanks to all guys for your precious help !! – rmonjo Feb 21 '10 at 18:24
2

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?

  • 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 – rmonjo Feb 22 '10 at 19:44
1

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
  • 64,370
  • 15
  • 118
  • 145
  • Bonjour only advertises the availability of services across the network. It doesn't provide file transfer capabilities. – Joshua Nozzi Feb 21 '10 at 15:48
  • 1
    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 Feb 21 '10 at 15:52
0

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.

Christopher Pickslay
  • 17,523
  • 6
  • 79
  • 92