我想删除服务器上的多个文件,我需要将多个参数值发送到服务器。例如:upload_id="11,12,13",每个值都是一个以逗号分隔的字符串。我使用了 NSArray 但它不起作用。服务器响应不成功。这是我的代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if([_tableView cellForRowAtIndexPath:indexPath].accessoryType == UITableViewCellAccessoryCheckmark){
[_tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryNone;
}else{
[_tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;
}
NSArray *selectedRows = [_tableView indexPathsForSelectedRows];
for (NSIndexPath *indexPath in selectedRows) {
uploadidString =[uploadidArray objectAtIndex:indexPath.row];
}
[iduploadArray insertObject:uploadidString atIndex:0];
NSLog(@"ID UPLOAD Array %@",iduploadArray);
}
-(void) deleteItems
{
NSURL *url1 = [NSURL URLWithString:@"http://myserver"];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL: url1] ;
NSDictionary *params1 = @{
@"upload_id" : [NSArray arrayWithObjects:iduploadArray,nil],
};
NSMutableURLRequest *afRequest = [httpClient requestWithMethod:@"POST" path:nil parameters:params1] ;
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:afRequest];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Success");
NSString * parsexmlinput = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
NSLog(@"Response in Delete items: %@", parsexmlinput);
[self parseXMLFile:parsexmlinput];
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"error: %@", error);
}
];
[httpClient enqueueHTTPRequestOperation:operation];
}
你有什么建议吗?