Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7833697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:50:49+00:00 2026-06-02T12:50:49+00:00

I have an app that allows users to save and open text files. Saving

  • 0

I have an app that allows users to save and open text files. Saving and opening files is fairly straightforward and easy, but I have to give the user an easy way to select a file to open. I decided to do this with a UITableView.

When the TableView loads in my view controller, my goal is to populate the TableView with the names of all of the user’s text files from within the Documents folder (part of the iOS App Sandbox).

I have a general idea of how to do this:

  1. Get the contents of the Documents folder and place it in an array

    NSString *pathString = [[NSBundle mainBundle] pathForResource:@"Documents" ofType:@"txt"];
    NSArray *fileList = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:pathString error:nil];
    NSLog(@"Contents of directory: %@", fileList);
    

    But this always returns: (null) in the output window. What is the path for my app’s document folder?

  2. Place the array in the UITableView

    I figured I’d use the numberOfRowsInSection method to do this. Is this the right place for performing this type of operation? Of should I use a different method?

  3. Finally, the app will get the value of the selected cell and use that value to open the file.


My main question here is: How can I place items (particularly the contents of directory) into an NSArray and then display that array in a UITableView?

Any help is much appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T12:50:54+00:00Added an answer on June 2, 2026 at 12:50 pm

    You can get the path using:

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    

    You can get the contents of the directory using:

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSArray *fileList = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirectory error:nil];
    

    As for displaying an NSArray in a UITableView, you should review Apple’s documentation on UITableView Data Source protocol:

    http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewDataSource_Protocol/Reference/Reference.html

    You use the cellForRowAtIndexPath method to actually populate the table, something like this would work:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"];
    
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MyIdentifier"] autorelease];
        }
    
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        cell.textLabel.text = [fileList objectAtIndex:indexPath.row]
    
        return cell;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a topics app that allows users to create topics. For each individual
I have an existing web app that allows users to rate items based on
We have a WPF app that allows our users to download encrypted content and
I have developed an app that allows the user to fill out text fields
OK, well I've been working on a simple app that allows users to save
I have a Silverlight 3 app that that will let users download PDF files
We have an Ruby on Rail app that allows the user to save a
I have an app that allows the user to take and save a new
I have an app that allows the user to choose an image, at design
I have an app that allows the user to choose a picture from their

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.