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

  • Home
  • SEARCH
  • 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 7759359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:36:29+00:00 2026-06-01T13:36:29+00:00

I have a folder in my app named Files. I would like to display

  • 0

I have a folder in my app named “Files”. I would like to display all of those TXT Files in a Table View, and then be able to click on each one to open it up in a different Controller. I have the functionality of it all working, but the issue lies in the name listed on the Table View. It is giving the entire working path of the TXT file, while I need only the File Name. I know that NSString can use a lastComponentPath line of code to return it, but cell text cannot come from an NSString. So, how do I get it to return the name of the file, and list it properly in the Table View? Here is my current code:

NSBundle *bundle = [NSBundle mainBundle];
self.files  = [bundle pathsForResourcesOfType:@"txt" inDirectory:@"Files"];
NSString *documentsDirectoryPath = [self.files objectAtIndex:thepath.row];
self.title = @"My Files";
self.filenames = [[documentsDirectoryPath lastPathComponent] stringByDeletingPathExtension];

For the cell content it is:

cell.textLabel.text = [self.files objectAtIndex:indexPath.row];

So, I tried putting in self.filenames but an NSString won’t respond to indexPath.row. So, how can I load the files from the self.files array, but display names from self.filenames string?

  • 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-01T13:36:30+00:00Added an answer on June 1, 2026 at 1:36 pm

    You should do the conversion of the filename in your cellForRowAtIndexpath: method.

    NSString *filename = [[[self.files objectAtIndex:indexPath.row] lastPathComponent] stringByDeletingPathExtension];
    cell.textLabel.text = filename;
    

    That way each time a cell is rendered it will access the correct object in your array and manipulate the value according to your needs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a folder with two files: Awesome.File.20091031_123002.txt Awesome.File.Summary.20091031_123152.txt Additionally, a third-party app handles
I have a folder in my WPF app Images that has several .png files
I am trying to setup a public_html/django_app folder, where all urls like ~/{username}/django would
We have a folder where our app will be potentially reading, writing and creating/deleting
I have a folder within a site that is a seperate web app than
I am making an example app of a game. I have a folder i
I have a web app using forms authentication and I have restricted a folder
I have a MVC3 application with some XML files on the App_Data folder. To
I have an app launching an executable which is in the same folder as
I am working on a django app. One part would involve uploading files (e.g.

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.