Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kage777

macrumors newbie
Original poster
Feb 24, 2008
20
0
Hi,

I'm am pretty new to iphone developing and am trying to write an app that first gets the contents of a file off of a shared folder on a windows machine over a wifi connection.

I was wondering if I could tell me if I could use initWithContentsOfURL to do this or not? and if not is there a way to do this?

thanks
 
I doubt it will work if its a Windows machine, but I haven't tried it myself.
 
Hi,

I'm am pretty new to iphone developing and am trying to write an app that first gets the contents of a file off of a shared folder on a windows machine over a wifi connection.

I was wondering if I could tell me if I could use initWithContentsOfURL to do this or not? and if not is there a way to do this?

thanks

This will only work if you can access the given file through a URL. I doubt you can though.
 
after doing some more research it seems I can't use this, but instead need a samba client for the iphone, but can't seem find one.

there are a couple of apps that seem like they can do this (data case, filesync),
so it seems like it should be possible.

but I can't figure out how to do it....any ideas?
 
Wow, I never knew about initWithURL until I read this. I can find thousands of useful ways to use it and interact with my website. I don't know about web servers or files (sorry to disappoint) but I just want to say how helpful this post has been even if it wasn't meant to be.
 
Actually it's a bad idea to use initWithContentsOfURL. It is a synchronous call. If the network isn't working well it may take 30 seconds to time out. And the watchdog will kill your app if it doesn't do anything for 20 seconds.

Use the asynchronous method with NSURLConnection instead.

Oh and by the way it's simple to set up your Mac's web sharing to allow your app running on the device to download files directly from your Mac. I do this for testing.
 
You mentioned it is easy to set up a Mac to download directly from it, but can it be done without an internet connection? What if I just have a closed network between the machine and the phone?

Also can it be done on a Windows machine, as the file I need to get off only is made from a program that is windows only?

thanks for the help
 
You can connect from your device to your Mac via WiFi. No internet connection is required.

All you need to do is turn on Web Sharing on the Mac. Put your files that you want to download in the ~/Sites folder. When you turn on web sharing you'll see the URL for 'your personal website.' Just use NSURLConnection to download the files from that URL.

In theory this can also be done on Windows. There is a web server called IIS that is available for Windows. If you use that you should be able to download files served by that web server from a Windows machine. I haven't tried this with Windows but it should work fine.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.