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

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
Should I use the scanf or fgets to read in the file names of my PDF docs I have sitting in a directory in the phone? I want to display the name of the items in a tableview. I was unsure how to read in the file names that I would add to an NSArray.

Thanks.
 
Look through the NSFileManager docs. You can read in the names of all the files in a folder in one method call.
 
Sorry, it was a dumb question. I was at the airport waiting on a 4 hour layover to Sweden. I had internet on my phone but not on my computer. I had no idea that the doc's needed the internet to work!

Suddenly I had to rely on my memory and not the internet and doc's to help me with the answer. it is so slow using my iphone with data roaming to search anything. After 30 minutes I was able to reason it out. When I did I knem my scanf and fgets was the wrong thing to ask for.

This code worked fine. Although I thought it was strange that I could not use the contentsOfDirectoryAtPath: with a mutableArray, it kept giving me a error so I used this code and then copied it to a mutableArray

Code:
-(void)readInDirectoryItems{
    NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/PDF"];
    NSFileManager *fileMgr = [NSFileManager defaultManager];
    NSArray *tempArray = [fileMgr contentsOfDirectoryAtPath:documentsDirectory error:nil];
    itemsInDirectoryArray = [NSMutableArray arrayWithArray:tempArray];
    
    [self.tableView reloadData];
}

By the way, can I download the docs to my computer or does it allways need to relly on an internet connection?
 
Here is the window
docs.jpg
 
Wirelessly posted (Mozilla/5.0 (iPhone; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3)

If you do want viewable documentation on your iPhone or iPad, I've found that Apple has made several of them available as iBooks. It seems the rest are available as PDF files which iBooks does quite well at displaying. It's not a replacement for a computer, mind you, but it works great in a pinch.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.