在删除任何行时,始终删除最后一行,而不在ios目标c中删除多行

在删除任何行时,始终删除最后一行,而不在ios目标c中删除多行,ios,objective-c,uitableview,delete-row,Ios,Objective C,Uitableview,Delete Row,我可以看到您正在从本地阵列中删除对象,而没有更新服务器上已删除的记录 现在您正在请求已删除记录的列表(通过myMethod函数),显然该记录将不在您的web列表中 所以,在重新加载列表后,该记录将可见,并且由于您将总记录递减1,所以您将无法看到最后一条记录 另外,不要重新加载整个表,只需根据需要重新加载行和节。那么,我应该如何做才能从本地数组和服务器中删除数据。请检查示例一。在该链接中,它们可能对您有用。它们只是从数组中删除数据,而不是从api中删除数据。因此,从api中删除数据后,您可以重新加

我可以看到您正在从本地阵列中删除对象,而没有更新服务器上已删除的记录

现在您正在请求已删除记录的列表(通过myMethod函数),显然该记录将不在您的web列表中

所以,在重新加载列表后,该记录将可见,并且由于您将总记录递减1,所以您将无法看到最后一条记录


另外,不要重新加载整个表,只需根据需要重新加载行和节。

那么,我应该如何做才能从本地数组和服务器中删除数据。请检查示例一。在该链接中,它们可能对您有用。它们只是从数组中删除数据,而不是从api中删除数据。因此,从api中删除数据后,您可以重新加载tableview数据
     - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

           return result.count;

        }
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

       static NSString *CellIdentifier = @"cell";

       UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];


       if (cell) {


           name = (UILabel *)[cell viewWithTag:10];
           name.text = [result objectAtIndex : indexPath.row];
       }

       else{

           name.tag=indexPath.row;
       }

       return cell;


    }


    - (IBAction)butn:(id)sender {


       [myTbl setEditing:YES animated:YES];

    }
    - (UITableViewCellEditingStyle)tableView:(UITableView *)aTableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
    {

       if (self.tbl.editing)
       {
           return UITableViewCellEditingStyleDelete;
       }

       return UITableViewCellEditingStyleNone;
    }

    - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath    

       if (editingStyle == UITableViewCellEditingStyleDelete) {

           [result removeObjectAtIndex:indexPath.row];
           [self myMethod];//in this method i'm deleting the data from api also
           [tableView reloadData];

       }

    }



    - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
    {
       return YES;
    }



  -(void)myMethod{


        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www.remove.php"]];
        NSData *data = [string dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
        [request setHTTPMethod:@"POST"];
        [request setHTTPBody:data];


        NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration
defaultSessionConfiguration]];
        [[session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable
 response, NSError * _Nullable error) {
            NSDictionary *JSON= [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers
 error:nil];

            NSArray *alertArray = [JSON objectForKey:@"removebookmark"];



      for (NSDictionary *alert in alertArray )

          {

                if ([[alert objectForKey:@"status"] isEqualToString:@"remove"])


                {
                                nslog(@"removebookmark");
                                [spinner stopAnimating];

                }

            }



        }]resume];


     }

@end