在哪里加载

时间:2009-07-18 17:35:09

标签: objective-c iphone-sdk-3.0 connection

在我的应用程序中,我与Web服务有联系,我想创建一个加载视图,以便在每次连接开始时显示,直到它返回响应。

在我的应用程序中放置此视图的最佳位置在哪里?实现它的最佳方法是什么?

谢谢,

佛明

1 个答案:

答案 0 :(得分:0)

NSURL * url = [NSURL URLWithString:@“http://.....?WSDL”];

NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];

NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];

[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];

[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];

[theRequest setHTTPMethod:@"POST"];

[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]]; 

NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

[theConnection start];

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {

[webData appendData:data];

}