我正在编写一个需要连接到返回和整数的 web 服务的 iPad 应用程序,如下所示:
<int xmlns="http://schemas.microsoft.com/2003/10/Serialization/">0</int>
我的代码看起来像这样
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:verficationURL]];
[request setHTTPMethod:@"GET"];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
}
-(void) connection: (NSURLConnection *)connection didReceiveData:(NSData *)data{
[self.responseData appendData:data];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *result = [[NSString alloc] initWithData:self.responseData encoding:NSUTF8StringEncoding];
NSLog(@"array: %s", result);
}
连接确实完成了加载,但我无法从结果中获取值 0。这样做的正确方法是什么。谢谢你