Objective c 停止将图像上载到web服务器?
我有一个iPhone应用程序,它有一个要上传到web服务器的图片队列。问题是:如何创建iAction来停止上传?以下是我的代码片段:Objective c 停止将图像上载到web服务器?,objective-c,xcode,ios4,task-queue,Objective C,Xcode,Ios4,Task Queue,我有一个iPhone应用程序,它有一个要上传到web服务器的图片队列。问题是:如何创建iAction来停止上传?以下是我的代码片段: NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:[NSURL URLWithString:urlString]]; [request setHTTPMethod:@"POST"]; NSString *boundary
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];
NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"];
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
[request addValue:contentType forHTTPHeaderField:@"Content-Type"];
NSMutableData *body = [NSMutableData data];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"userfile\"; filename=\".jpg\"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:@"Content-Type: binary\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[NSData dataWithData:imageData]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:body];
谢谢,
库尔顿 我相信这将回答您所有的问题和更多:) 它包含大量的信息、大量的示例,并使用Asynchronous,这样您的UI就不会被阻塞。再往下看,它会告诉你发送数据的方式和你想做的完全一样,但我建议你从上面读,因为它会告诉你其他重要的事情