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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:59:42+00:00 2026-06-05T05:59:42+00:00

Am am making a task organizer iOS app. You type a task and it

  • 0

Am am making a task organizer iOS app. You type a task and it is saved in an array. I wanted people to be able to share the tasks between Phones so i added a way to save each Array.

Right now I am using my idea locally. The page has a title and a password. When the save button is pressed the array is saved to a file (This works very well and it saves every time) that is unique to the Title and Password.

I need to find a way to then get all the information in the file back to the array so it can be seen. This is what i have tried and keep in mind that everything works fine except for the “get tasks button” my problem is in the getFile void:

BNRAppDelegate.m

#import "BNRAppDelegate.h"

NSString *docPath()
{
    NSArray *pathList = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                                            NSUserDomainMask,
                                                            YES);
    return [[pathList objectAtIndex:0] stringByAppendingPathComponent:@"data.td" ];
}

@implementation BNRAppDelegate

@synthesize window = _window;

#pragma mark - Application delegate callbacks

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath 
{
    return YES;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary     *)launchOptions
{
    NSArray *plist = [NSArray arrayWithContentsOfFile:docPath()];
    if (plist)
    {
        tasks = [plist mutableCopy];
    }
    else
    {
        tasks = [[NSMutableArray alloc] init];
    }

    CGRect windowFrame = [[UIScreen mainScreen] bounds];
    UIWindow *theWindow = [[UIWindow alloc] initWithFrame:windowFrame];
    [self setWindow:theWindow];

    [[self window] addSubview:taskTable];
    [[self window] addSubview:taskField];
    [[self window] addSubview:titleField];
    [[self window] addSubview:insertButton];
    [[self window] addSubview:clearButton];
    [[self window] addSubview:shareButton];
    [[self window] addSubview:passField];
    [[self window] addSubview:getButton];

    [[self window] setBackgroundColor:[UIColor whiteColor]];
    [[self window] makeKeyAndVisible];

    return YES;
}
- (void)addTask:(id)sender
{
    NSString *t = [taskField text];

    if ([t isEqualToString:@""]) {
        return;
    }

    [tasks addObject:t];
    [taskTable reloadData];
    [taskField setText:@""];
    [taskField resignFirstResponder];    
}
- (void)takeTask:(id)sender
{
    [tasks removeAllObjects];
    [taskTable reloadData];
    [tasks writeToFile:docPath()
            atomically:YES];
}
- (void)saveTask:(id)sender;
{
    if ([titleField text] == @""){
        //
    } else {
        NSString * original = [titleField text];
        NSString * pass = [passField text];
        NSString * step = [NSString stringWithFormat:@"%@.%@", original, pass];
        NSString * file = [NSString stringWithFormat:@"%@.plist", step];

        [tasks writeToFile:[NSString stringWithFormat:@"/tmp/%@", file] 
                atomically:YES];
        [tasks writeToFile:docPath()
                atomically:YES];
    }
}
- (void)getFile:(id)sender;
{
    NSString * original = [titleField text];
    NSString * pass = [passField text];
    NSString * step = [NSString stringWithFormat:@"%@.%@", original, pass];
    NSString * file = [NSString stringWithFormat:@"%@.plist", step];

    NSMutableArray *theTasks = [NSMutableArray arrayWithContentsOfFile:[NSString stringWithFormat:@"/tmp/%@", file]];
    tasks = [theTasks mutableCopy];

    [tasks writeToFile:docPath()
            atomically:YES];
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:  (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{ 
    if (editingStyle == UITableViewCellEditingStyleDelete) { 
        [tasks removeObjectAtIndex:indexPath.row]; [tableView deleteRowsAtIndexPaths:[NSArray   arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; 
    } 
}

#pragma mark - Table View management

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [tasks count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *c= [taskTable dequeueReusableCellWithIdentifier:@"Cell"];

    if (!c) {
        c = [[ UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
    }

    NSString *item = [tasks objectAtIndex:[indexPath row]];
    [[c textLabel] setText:item];

    return c;

} 
- (void)applicationDidEnterBackground:(UIApplication *)application
{
    [tasks writeToFile:docPath()
            atomically:YES];
}
- (void)applicationWillTerminate:(UIApplication *)application
{
    [tasks writeToFile:docPath()
            atomically:YES];
}

@end

Please Help if you can Thank You.

  • 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-05T05:59:44+00:00Added an answer on June 5, 2026 at 5:59 am

    I think you are doing it on the wrong way. I dont know what is the used of the data.td on your code since you want to save it as username.password.plist

    Please try this one, and it might guide you how save and retrieve files locally base on your code.

    NSString *pathPlist(NSString *filename)
    {
        NSArray *pathList = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                                                NSUserDomainMask,
                                                                YES);
        return [[pathList objectAtIndex:0] stringByAppendingPathComponent:filename];
    }
    
    - (void)saveTask:(id)sender {
        NSString * original = @"Hello";
        NSString * pass = @"123";
        NSString * step = [NSString stringWithFormat:@"%@.%@", original, pass];
        NSString * file = [NSString stringWithFormat:@"%@.plist", step];
    
        NSString *path = pathPlist(file);
        NSMutableArray *array = [[NSMutableArray alloc] init];
        if (path) {
            NSArray *data = [NSArray arrayWithContentsOfFile:path];
            if (data) {
                [array setArray:data];
            }
            [array addObject:@"My Task"];
            BOOL iswritten = [array writeToFile:path atomically:YES];
            if (!iswritten) {
                NSLog(@"Failed");
            }
            [data release];
        }
    }
    
    - (void)getFile:(id)sender {
        NSString * original = @"Hello";
        NSString * pass = @"123";
        NSString * step = [NSString stringWithFormat:@"%@.%@", original, pass];
        NSString * file = [NSString stringWithFormat:@"%@.plist", step];
    
        NSString *path = pathPlist(file);
        NSMutableArray *array = [[NSMutableArray alloc] init];
        if (path) {
            NSArray *data = [NSArray arrayWithContentsOfFile:path];
            if (data) {
                [array setArray:data];
            }
        }
        NSLog(@"%@", array);
    }
    

    Note: The var array holds the data from the filename(username.password.plist)

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

Sidebar

Related Questions

I'm making a task-based program that needs to have plugins. Tasks need to have
I am working on alarms and making an app for task reminder. I am
I'm making a checklist for people to do tasks on our company website. The
I am trying to accomplish the task of Making a Web request ->getting result
When making relations between tables (in mysql), I have encountered a naming dilemma. For
I have a schedule task that is making a webrequest. This was all working
I'm making an ASP.Net MVC 3 application in VS 2010. I have a task
im making a task manager application (server-client) .. so i get processors list from
I'm making an application that allows users to view task lists stored in different
I'm making a WPF application using MVVM pattern. I found sometimes Task is significantly

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.