我下载了苹果的使用 HTTP POST 和 GET 的演示(他们的示例应用程序有一个带有不同部分的标签栏),代码太困惑了!
谁能给我一些示例代码或一些关于它的教程的链接? :)
谢谢!
最佳答案
Matt Long 的这个演练特别好: http://www.cimgf.com/2010/02/12/accessing-the-cloud-from-cocoa-touch/
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]
initWithURL:[NSURL
URLWithString:@"http://www.cimgf.com/testpost.php"]];
[request setHTTPMethod:@"POST"];
[request setValue:@"text/xml"
forHTTPHeaderField:@"Content-type"];
NSString *xmlString = @"<data><item>Item 1</item><item>Item 2</item></data>";
[request setValue:[NSString stringWithFormat:@"%d",
[xmlString length]]
forHTTPHeaderField:@"Content-length"];
[request setHTTPBody:[xmlString
dataUsingEncoding:NSUTF8StringEncoding]];
[[NSURLConnection alloc]
initWithRequest:request
delegate:self];
关于objective-c - 在 Objective-C 中在 iPhone 上使用 HTTP POST 和 GET 的教程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2346893/