使用webservice iOS删除数据

时间:2013-07-26 11:01:03

标签: iphone ios objective-c

如何使用网络服务删除数据?

我在UILabeluiOidCustomTableviewCell.h。现在我在ViewController.m中使用uiOid作为cell.uiOid.text=[orid objectAtIndex:indexPath.row];。这里oridNSMutablearray,用于从webservice中检索记录。我正确检索了数据,但我的问题是如何删除?我正在使用webservice删除数据。

我在

中插入了删除网络服务

//更新//

- (void)tableView:(UITableView *)aTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
  {      
    [desc removeObjectAtIndex:indexPath.row];
    [item removeObjectAtIndex:indexPath.row];
    [cpack removeObjectAtIndex:indexPath.row];
    [uprice removeObjectAtIndex:indexPath.row];
    [cprice removeObjectAtIndex:indexPath.row];
    [quantity removeObjectAtIndex:indexPath.row];
    [total removeObjectAtIndex:indexPath.row];
    [orid removeObjectAtIndex:indexPath.row];


    NSLog(@"%@",[uid objectForKey:@"OID"]);
    NSLog(@"%@",orid);


    NSString *soapmessage = [NSString stringWithFormat:
                             @"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
                             "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
                             "<soap:Body>\n"
                             "<DeleteValue xmlns=\"http://tempuri.org/\">\n"
                             "<oid>%@</oid>"
                             "</DeleteValue>\n"
                             "</soap:Body>\n"
                             "</soap:Envelope>\n",orid

                             ];

    NSLog(@"%@",soapmessage);

    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",appdev.hostname]];
    NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
    NSString *msgLength = [NSString stringWithFormat:@"%d", [soapmessage length]];

    [theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
    [theRequest addValue: @"http://tempuri.org/DeleteVaue" forHTTPHeaderField:@"SOAPAction"];
    [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
    [theRequest setHTTPMethod:@"POST"];
    [theRequest setHTTPBody: [soapmessage dataUsingEncoding:NSUTF8StringEncoding]];

}

[mytableview reloadData];

}

方法。当我输入静态编号“89291”时,数据已成功删除(对多个操作无用)。但我想在webservice中传递orid (NSMutableArray)而不是静态数字。我怎样才能解决这个问题? 谢谢你的帮助。

2 个答案:

答案 0 :(得分:0)

在您的删除服务方法中传递此内容:

[orid objectAtIndex:indexPath.row];

每次从表中删除行时都会执行。之后:

[orid removeObjectAtIndex:indexPath.row];
[aTableView reloadData];

答案 1 :(得分:0)

从yourDataAry中删除

[orid removeObjectAtIndex:indexPath.row];
[yourTableView reloadData];  

并使webService也从ServerDataBase中删除此记录。