// 发 送同步请求, 这里得returnData就是返回得数据了 NSData *returnData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:nil error:nil]; NSString * rtnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding]; DLog(@"同步调用后,返回的内容是:%@", rtnString);
异步调用的方法可以查看 这个
http://www.zhaorong.me/archives/1274
RemoteMethodCall * rpc = [[[RemoteMethodCall alloc] init] autorelease]; NSMutableURLRequest *urlRequest = [rpc getCustomerActivation:self.udid]; //请求 NSURLConnection *theConnection = [[[NSURLConnection alloc] initWithRequest:urlRequest delegate:self] autorelease]; theConnection = nil; 需要实现 以下几个 异步方法 - (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSHTTPURLResponse*)response - (void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data - (void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error - (void)connectionDidFinishLoading:(NSURLConnection *)connection