Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 11, 2013, 05:56 PM   #1
DavidBlack
macrumors 6502
 
Join Date: Jan 2013
Location: Somewhere In Apple's HQ ;)
How to Delete Row

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?

Last edited by robbieduncan; Feb 12, 2013 at 04:17 AM. Reason: Please use code tags
DavidBlack is offline   0 Reply With Quote
Old Feb 11, 2013, 07:00 PM   #2
Mac_Max
macrumors 6502
 
Join Date: Mar 2004
I believe you're looking for this method:

removeRowsAtIndexes:withAnimation:
Mac_Max is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
iPhone ewon't delete emails when I delete them on my MacBook and I macs. johnstonimages iCloud and Apple Services 3 Mar 12, 2013 10:00 PM
If I delete a photo from iPhoto does it delete it in the folder completely? bobright iMac 6 Jan 3, 2013 08:05 PM
Why doesn't my iPhone delete emails when I delete them on my MacBook GeneParmesan iOS 5 and earlier 4 Sep 26, 2012 12:17 PM
Delete a row from Core Data UITableView with custom button mdhansen5 iPhone/iPad Programming 1 Jun 14, 2012 02:24 PM

Forum Jump

All times are GMT -5. The time now is 09:14 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC