- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.responseData = [NSMutableData data]; //NSURLRequest *request = [NSURLRequest requestWithURL: //// [NSURL URLWithString:@"https://maps.googleapis.com/maps/api/place/search/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=//false&key=AIzaSyAbgGH36jnyow0MbJNP4g6INkMXqgKFfHk"]]; //NSURLRequest *request = [NSURLRequest requestWithURL: //[NSURL URLWithString:@"http://162.242.142.88/CarShareService/CarShareService.svc/Login?UserName=alex@rentcentric.com&Password=12345"]]; NSString * key = [NSString stringWithFormat:@"UserName=%@&Password=",@"alex@rentcentric.com" ,@"12345" ]; NSURL * url = [NSURL URLWithString:@"http://162.242.142.88/CarShareService/CarShareService.svc/Login"]; NSMutableURLRequest * request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"GET"]; [request setHTTPBody:[key dataUsingEncoding:NSUTF8StringEncoding]]; [[NSURLConnection alloc] initWithRequest:request delegate:self]; } - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { NSLog(@"didReceiveResponse"); [self.responseData setLength:0]; } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [self.responseData appendData:data]; } - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { NSLog(@"didFailWithError"); NSLog([NSString stringWithFormat:@"Connection failed: %@", [error description]]); } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { NSLog(@"connectionDidFinishLoading"); NSLog(@"Succeeded! Received %d bytes of data",[self.responseData length]); // convert to JSON NSError *myError = nil; NSDictionary *res = [NSJSONSerialization JSONObjectWithData:self.responseData options:NSJSONReadingMutableLeaves error:&myError]; //[self setResponseSerializer:responseData]; NSDictionary *posts = [res objectForKey:@"StatusInfo.StatusCode"]; if(res == nil){ NSLog(@"JSON Error: %@", myError); return; }else{ NSLog(@"JSON Error%@",myError); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)