Search code examples
iosuitableviewnotepad

Notepad app and databases


I am making an app that has a basic tableview where users can add data to the table, just for within their own version of the app. Needs to be on the iPhone alone, so no internet connection to a database etc.

Now having a look at the native notepad app it looks like that is what I am after - so when the user presses a + button, it then goes to another UIView and the user can enter their data and then the title of the or the first line is set in the table view.

Is there a tutorial for this, or in what area am I suppose to look for this? At the moment, I can add a hardcoded string into the app by using this code, which i assume is the bit I need to mofidy:

- (void)tableView:(UITableView *)aTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
forRowAtIndexPath:(NSIndexPath *)indexPath 
{   
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        [arryData removeObjectAtIndex:indexPath.row];
        [tblSimpleTable reloadData];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        [arryData insertObject:@"Mac Mini" atIndex:[arryData count]];
        [tblSimpleTable beginUpdates];
        [tblSimpleTable endUpdates];
    }
}

Am I on the right track here?

Cheers -Jeff


Solution

  • On -viewDidDisappear in the new UIViewController, you could have it update an NSArray that would get passed between the views with a delegate method. You could store an array filled with the strings of the titles, then just has the tableView update when -viewWillAppear is called.