任何人都可以粘貼一些關於如何做一對夫婦值的http post的代碼?如何在iPhone上的可可中做一個http post?
0
A
回答
-2
這裏是所行的一個POST調用一些基本代碼:
//url is the appropriate url for the http POST call
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
[theRequest setHTTPMethod:@"POST"];
NSURLConnection *theConnection = [[NSURLConnection alloc]initWithRequest:theRequest delegate:self];
if(theConnection)
{
webData = [[NSMutableData data]retain];
}
else
{
NSLog(@"theConnection is NULL");
}
您需要實現合適的NSURLConnection的委託方法。
0
在谷歌搜索的第二個答案看起來像什麼,你可能需要:
0
//可以驅動一個同步NSURLConnection的使用sendSynchronousRequest:returningResponse:錯誤: //但直到接收到響應
其將阻止整個螺紋// thebodyData =有效載荷發送到服務器(在正確的格式) // theMimeType =有效載荷的mineType // url是適用於http POST調用的url
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
[theRequest setHTTPMethod:@"POST"];
NSURLConnection *theConnection = [[NSURLConnection alloc]initWithRequest:theRequest delegate:self];
if(theConnection)
{
webData = [[NSMutableData data]retain];
// give the details of the payload -- mine time and body content.
[theRequest setValue: theMimeType forHTTPHeaderField:@"Content-Type"];
[theRequest setHTTPBody:theBodyData];
}
else
{
NSLog(@"theConnection is NULL");
}
// the delegate methods templates...
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
[webData setLength:0]; // clear the data incase it was a redirect in between.
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[webData appendData:data]; // collect the data from server as it comes in.
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
[[NSAlert alertWithError:error] runModal]; // report the error
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
// Once this method is invoked, "webData" contains the complete result
}
相關問題
- 1. javafx在webenigne做一個http post請求
- 2. 我可以通過一個cookie在我的http post與clj-http
- 3. 可可HTTP POST請求
- 4. 做一個HTTP POST使用C#
- 5. 如何做一個HTTP POST使用cURL的價值清單
- 6. Meteor.js - 我可以爲我的Meteor應用程序做一個HTTP POST嗎?
- 7. 我可以在「HTTP POST」中使用「dataWithContentsOfURL」
- 8. 如何在iPhone上設置一個不可觸摸的uitableviewcell sdk
- 9. 如何做一個可以Freezable的UserControl?
- 10. 如何做一個可笑的寬圖
- 11. 我可以在同一頁MVC上做AcceptVerbs(HttpVerbs.Get/Post)和hijaxing嗎?
- 12. 如何做一個http post傳遞複雜對象?
- 13. 如何做一個登錄離子與http post?
- 14. iPhone - 如何可以我週一上班
- 15. 可可HTTP POST方法驗證
- 16. HTTP POST可以改變嗎?
- 17. 我可以做一個應用程序,如在iOS中查找我的iPhone?
- 18. 如何只發送一個字符串與http Post在Android上?
- 19. 如何使用HTTP POST方法iphone
- 20. 是否有可能在iPhone上做一個漂亮的過濾器?
- 21. 從PHP到HTTP處理程序做一個HTTP POST
- 22. 如何從iPhone上傳使用HTTP POST的音頻文件?
- 23. 可能在LINQ中做一個聯合?
- 24. 在jquery上的多個對象上做一個.post準備
- 25. Jquery $ .post() - 可以做一個完整的頁面發佈請求?
- 26. 做一個HTTP POST到一個REST端點
- 27. AFNetworking - 做一個HTTP POST到REST,發送一個JSON Base64string圖像
- 28. 如何發送一個http basic auth post?
- 29. iPhone應用程序崩潰在http post上使用asi-http-request
- 30. 是否可以在iPhone上的UIToolBar中放置一個按鈕?