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

lynkynpark86

macrumors 6502
Original poster
Hello,
I am making an app to play video files added by the user (by ssh, etc. It will be a jailbreak app). I am going to have a TableView with the videos in directory "/var/mobile/Media/Vid". How can I make it so an NSArray is set to the list of files in that directory (/var/mobile/Media/Vid)?
 
Look at the NSFileManager documentation, in particular the contentsOfDirectoryAtPath:error: method.

I've been working on it, and I can't quite get it to work. Here's my code:
Code:
NSArray *dirList = [[NSFileManager defaultManager] directoryContentsAtPath:@"/var/mobile/Media/Vidly"];
Is there anything wrong with this? I get no errors, but the tableview is blank, despite there being files in that directory. Ideas?
 
Last edited:

I don't have a jailbroken phone or any interest in supporting them. On a non-jailbroken device (and quite possibly on the simulator) your code cannot read from that directory so in those cases I'd expect you'd get an empty array. You'll probably get a better response on forums more jailbrake development oriented: most posters here are not developing for jailbroken phones.

Edit to add: you should also be supplying the error: parameter even if you pass nill to it. Without it the method name is not complete and won't work. Ultimately you'd be better supplying an error object so as you can check for errors that might tell you what is going wrong.

What I am suggesting is:
Code:
NSError *error;
NSArray *dirList = [[NSFileManager defaultManager] directoryContentsAtPath:@"/var/mobile/Media/Vidly" error:&error];
if (error!=nil)
{
// Check the error
}

Note I typed that straight in here: you need to check for typos or silly logic errors!
 
Nod taht eye dond appriciate teh replie, buut doz thayt rilly hellp mii owt mutch?

How could I tell? I don't have your device.

You posted two inconsistent pathnames. I pointed out the inconsistency. It's up to you to confirm that one of them is, in fact, correct.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.