I develop an application in which I need to delete the rows from array as well as database..?In cellForRowAtIndexPath I write like cell.textLabel.Text=[myarray.objectAtIndexPath.row]; I Want to delete that row from database and array also.In Editing method I write the code like
MoneyAppDelegate *mydelegate=(MoneyAppDelegate *)[[UIApplication sharedApplication]delegate];
if (editingStyle == UITableViewCellEditingStyleDelete)
{
database *objdata=[[database alloc]init];
[app deleteCategory:objdata];
[self.mytableview deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
But it not work. In deletecategory method I have code like
-(void)deleteCategory:(database *)databaseObj
{
[databaseObj deleteCategory];
[myarray removeObject:databaseObj];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MoneyAppDelegate *app = (MoneyAppDelegate *)[[UIApplication sharedApplication]delegate];
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
}
cell.textLabel.text = [app.myarray4 objectAtIndex:indexPath.row];
return cell;}
deletecategory is the method to delete the record from Database.nothing else. How can i delete that selected row from database I know its very simple but yet I confused..thnanx in advance:)