Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-07-2010, 05:56 PM   #1 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 19
Default Get an array of files in a URL?

Hi, I need to get an array (potentially a UITableView) of items in a url (Directory) So if http://www.example.com/files was the url, i need an array of all the items in that directory.

I looked at NSArray's arrayWithContentsOfURL: method, but I'm really stumped by this one.

Thanks guys-
Steake
Steake is offline   Reply With Quote
Old 01-07-2010, 06:21 PM   #2 (permalink)
jsd
at this moment
 
Join Date: Mar 2009
Location: San Francisco, CA
Posts: 900
Default

You'll have to get the contents of the URL into a string and then parse the string for filenames. Don't use the xxxWithContentsOfURL functions unless you're just messing around - they completely lock up your app while they are running.
jsd is offline   Reply With Quote
Old 01-07-2010, 07:23 PM   #3 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 19
Question

Quote:
Originally Posted by jsd View Post
You'll have to get the contents of the URL into a string and then parse the string for filenames. Don't use the xxxWithContentsOfURL functions unless you're just messing around - they completely lock up your app while they are running.
Well I could put it on another thread...

But it matters not-

I need to retrieve a directories contents.. It's not HTML, it's a directory so I need to enumerate that.

Does anybody know how to do that?

Thanks so much

Steake.
Steake is offline   Reply With Quote
Old 01-07-2010, 07:24 PM   #4 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 271
Default

Write a php script to do that serverside then parse it clientside
__________________
@rarindeed


Burstly is the only open and free ad management platform for iPhone app developers.
rarindeed is offline   Reply With Quote
Old 01-07-2010, 07:27 PM   #5 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 19
Default

I would have done that, or used a PLIST for it - but I need this to be compatible with many different servers that aren't mine...

I'm sure there is a way to do this...
Steake is offline   Reply With Quote
Old 01-07-2010, 07:28 PM   #6 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 19
Default

Quote:
Originally Posted by jsd View Post
You'll have to get the contents of the URL into a string and then parse the string for filenames. Don't use the xxxWithContentsOfURL functions unless you're just messing around - they completely lock up your app while they are running.
I think you have the answer, do you have any idea how you might go about putting the contents of the URL into strings and parsing the results?

Thanks so much.
Steake is offline   Reply With Quote
Old 01-07-2010, 07:33 PM   #7 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 271
Default

If you have the directory listing (this is sort of an operating assumption in this whole thread, yeah?) then you can parse for <a> tags
__________________
@rarindeed


Burstly is the only open and free ad management platform for iPhone app developers.
rarindeed is offline   Reply With Quote
Old 01-07-2010, 07:39 PM   #8 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 19
Default

Quote:
Originally Posted by rarindeed View Post
If you have the directory listing (this is sort of an operating assumption in this whole thread, yeah?) then you can parse for <a> tags
So I can get the HTML of a directory, parse it and get the <a href=""> tags?

forgive my newbieness but how would *you* go about doing this?

You guys help so much
Steake is offline   Reply With Quote
Old 01-07-2010, 07:50 PM   #9 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 271
Default

Well you need a directory listing of some sort... either web server created or otherwise. Unless you have that I can't think of any way to do it. (not to say there isn't a way to do it :P )

I'd get the HTML of the listing and then just find the <a href=""> tags, yup. (Given the assumption that you can't get cleanly delimited/structured data)
__________________
@rarindeed


Burstly is the only open and free ad management platform for iPhone app developers.
rarindeed is offline   Reply With Quote
Old 01-07-2010, 08:07 PM   #10 (permalink)
jsd
at this moment
 
Join Date: Mar 2009
Location: San Francisco, CA
Posts: 900
Default

Quote:
Originally Posted by Steake View Post
Well I could put it on another thread...

But it matters not-

I need to retrieve a directories contents.. It's not HTML, it's a directory so I need to enumerate that.

Does anybody know how to do that?

Thanks so much

Steake.
I would use a server-side script that turns the directory listings into a JSON string and prints that. Then you just grab the URL in your iphone app and decode the json. Voila, you've got an array of filenames. (Or whatever other kind of data structures you need.)
jsd is offline   Reply With Quote
Reply

Bookmarks

Tags
nsarray, nsurl, steake, stumped, uitableview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 245
18 members and 227 guests
ADY, Alsahir, beleg_1998, Dani77, diyora, iDifferent, iph_s, JamesCahall, JasonR, mer10, Monstertaco, prchn4christ, Robiwan, Rudy, smithdale87, Speed, spiderguy84, timle8n1
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,756
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:16 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0