1,普通的DELETE只需加上下述一句code:
[request setRequestMethod:@"DELETE"];2,附带有参数表单的情况(一次删除请求):
ASIFormDataRequest *request; NSURL *baseURL = [NSURL URLWithString:@"http://www.baidu.com/xx/"]; request = [ASIFormDataRequest requestWithURL:baseURL]; //header [request addRequestHeader:@"Authorization" value:headerforAuthen]; //form [request setPostValue:username forKey:@"userpair_name"]; /// Call this before setting request method [request buildPostBody]; //构造请求 [request setRequestMethod:@"DELETE"]; //设置代理 [request setDelegate:self]; //设置超时 [request setTimeOutSeconds:10]; //url请求失败处理 [request setDidFailSelector:@selector(urlRequestFailed_DeleteUserPair:)]; //url请求成功处理 [request setDidFinishSelector:@selector(urlRequestSuccessed_DeleteUserPair:)]; //异步传输 [request startAsynchronous]; return YES;
现有要提交的数据:
[request setPostValue:username forKey:@"userpair_name"];
只添加
[request setRequestMethod:@"DELETE"];这行代码并不能正确实现DELETE,
需要添加
[request buildPostBody];另外注意 setRequestMethod:@"DELETE"这行要在buildPostBody之后。
参考:stackoverflow:http://stackoverflow.com/questions/15518394/asiformdatarequest-with-setpostvalue-and-method-delete
ios ASIHttpRequest库进行DELETE操作时delete带有参数表单的使用方法,布布扣,bubuko.com
ios ASIHttpRequest库进行DELETE操作时delete带有参数表单的使用方法
原文地址:http://blog.csdn.net/nohackcc/article/details/26345173