How to Delete Row

Discussion in 'Mac Programming' started by DavidBlack, Feb 11, 2013.

  1. DavidBlack, Feb 11, 2013
    Last edited by a moderator: Feb 12, 2013

    macrumors 6502a

    DavidBlack

    Joined:
    Jan 27, 2013
    Location:
    Somewhere In Apple's HQ ;)
    #1
    I want to delete a row when the user selects the remove button. On a mac table.


    This is the code I am using


    Code:
    - (IBAction)removepassword:(id)sender {
    
    
       
    
        NSDateFormatter *newFormatter = [[NSDateFormatter alloc] init];
        
        [newFormatter setDateStyle:NSDateFormatterShortStyle];
        
        NSString *billDueDate = [newFormatter stringFromDate:billDatePicker.dateValue];
        
        NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
                                    [txtName stringValue],@"Name",
                                    billDueDate, @"Date",
                                    [txtAmount stringValue], @"Amount",
                                    nil];
        
        [arrayBills removeObject:dictionary];
        
        if(![[NSFileManager defaultManager] fileExistsAtPath:billFile] || [[NSFileManager defaultManager] isWritableFileAtPath:billFile]){
            
            [[arrayBills arrangedObjects] writeToFile:billFile atomically:NO];
        }
    
    
    
    But it only works for one row also this is the code I have to add a row or cell
    
    
    -(IBAction)addBill:(id)sender{
        
        NSDateFormatter *newFormatter = [[NSDateFormatter alloc] init];
        
        [newFormatter setDateStyle:NSDateFormatterShortStyle];
        
        NSString *billDueDate = [newFormatter stringFromDate:billDatePicker.dateValue];
        
        NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
                                    [txtName stringValue],@"Name",
                                    billDueDate, @"Date",
                                    [txtAmount stringValue], @"Amount",
                                    nil];
        
        [arrayBills addObject:dictionary];
        
        [txtName setStringValue:@""];
        [txtAmount setStringValue:@""];
        
        if(![[NSFileManager defaultManager] fileExistsAtPath:billFile] || [[NSFileManager defaultManager] isWritableFileAtPath:billFile]){
            
            [[arrayBills arrangedObjects] writeToFile:billFile atomically:YES];
        }
    
    
    Can anyone please help?
     
  2. macrumors 6502

    Joined:
    Mar 8, 2004

Share This Page