配列とデータベースから行を削除する必要があるアプリケーションを開発しています..? cellForRowAtIndexPathでは、cell.textLabel.Text=[myarray.objectAtIndexPath.row]; その行をデータベースと配列からも削除したい.Editingメソッドでは、次のようなコードを記述します
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];
}
しかし、うまくいきません。deletecategory メソッドには、次のようなコードがあります
-(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 = @"セル";
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 は、Database.nothing からレコードを削除するメソッドです。選択した行をデータベースから削除するにはどうすればよいですか。非常に単純なことはわかっていますが、事前に混乱しました..