Delete record
Delete record
- Subject: Delete record
- From: Michèle Garoche <email@hidden>
- Date: Wed, 19 Dec 2001 05:50:51 +0100
From a newbie:
In Travel Advisor (Learning Cocoa - chapter 10), I've implemented as
mentioned below the method to delete a record.
Could someone tell me if it is the right way to do it?
Many thanks in advance.
- (IBAction)deleteRecord:(id)sender
{
Country *aCountry;
NSString *countryName = [countryField stringValue];
// Retrieve the key
aCountry = [countryDict objectForKey:countryName];
// Is there an entry in the dictionary for this key?
if (!aCountry)
{
return;
}
// Remove the entry in the dictionary
[countryDict removeObjectForKey:countryName];
[countryKeys removeObject:countryName];
// Sort array and update table view
[countryKeys sortUsingSelector:@selector(compare:)];
[countryTableView reloadData];
[self blankFields:self];
[countryField selectText:self];
}