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 3975256
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:39:49+00:00 2026-05-20T04:39:49+00:00

So, my app consists of a textview in one view controller. When the user

  • 0

So, my app consists of a textview in one view controller. When the user taps a save button, the text from that textview is written to a plist with this code:

- (IBAction)saveDoc:(id)sender

{
NSString *typedText = typingArea.text;
NSMutableArray *totalFiles = [[NSMutableArray alloc] init];

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"savedFiles.plist"];

[totalFiles addObject:typedText];

[totalFiles writeToFile:path atomically:YES];
[totalFiles release];
}

Then, in a totally separate view controller, I have a UITableView that displays the saved file using this code.:

- (void)viewDidLoad {

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectories = [paths objectAtIndex:0];
NSString *path = [documentsDirectories stringByAppendingPathComponent:@"savedFiles.plist"];

NSLog(@"Got Path: %@", documentsDirectories);




array = [[NSMutableArray alloc] initWithContentsOfFile:path];
NSLog(@"Loaded Array into new array: %@", array);

[super viewDidLoad];

// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
//self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

array is an NSMutableArray. Then I load it into the table view like this:

// Configure the cell...

    NSString *cellValue = [array objectAtIndex:indexPath.row];
    cell.textLabel.text = cellValue;

My question is, how do I make it so I can save multiple files and show multiple files in the table view. Right now, only one file can be saved and it is overwritten every time the save button is pressed.

Thanks in advance,

Tate

  • 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-05-20T04:39:49+00:00Added an answer on May 20, 2026 at 4:39 am

    My strategy is usually to make an NSDictionary and save the files with the key as the name of the file, and the object as your array. However before you do that one I think you need to check whether the current location has something inside.

    To do that:

    NSDictionary currentData = [NSDictionary dictionaryWithContentsOfFile:path];
    [currentData setValue:totalFiles forKey:@"firstArray"];
    [currentData writeToFile:path atomically:YES];
    

    You can of course improvise yourself. Check out documentation for NSDictionary, it’s a very useful data type IMO (but can get very complicated).

    Otherwise why don’t you just have another plist file? i.e. use savedFile.plist and savedFile2.plist or something like that?

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

Sidebar

Related Questions

No related questions found

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.