如何使用web服务删除数据?
我将UILabel
作为CustomTableviewCell.h
中的uiOid
。现在我在ViewController.m中使用uiOid
作为cell.uiOid.text=[orid objectAtIndex:indexPath.row];
。这里orid
是用于从Web服务检索记录的NSMutablearray
。我正确检索了数据,但我的问题是如何删除?我正在使用Web服务删除数据。
我在中插入了删除Web服务
//更新//
- (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)
,而不是静态数字。我该怎么解决这个问题?谢谢你的帮助。
从DataAry 中删除
[orid removeObjectAtIndex:indexPath.row];
[yourTableView reloadData];
并创建一个webService来从ServerDataBase中删除此记录。
在您的删除服务方法中传递此信息:
[orid objectAtIndex:indexPath.row];
它在每次从表中删除一行时执行。之后:
[orid removeObjectAtIndex:indexPath.row];
[aTableView reloadData];