We couldnt set the response data type from our request. Response is set from the server. From your description(web service return both XML and JSON), my guess is you need to post a status variable which showing the return status like isXML
. It's only my guess. You need to contact server side programmers about the implementation of this request.
EDIT Try below code
responseData = [[NSMutableData alloc]init];
NSURL *url = [[NSURL alloc] initWithString:@"http://192.168.1.1:8080/test2/eattel/restaurants"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setValue:@"application/json" forHTTPHeaderField:@"accept"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
(void)[NSURLConnection connectionWithRequest:req delegate:self];
Then You need to implement NSURLConnection Delegates.
#pragma mark - NSURLConnection Delegates
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
[responseData setLength:0];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[responseData appendData:data];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *responseString = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(@"%@",responseString);
}