I'm trying to run a get request using the iOS simulator but I'm not getting any response from the server and the data is not getting sent.
NSString *theGetURL = [NSString stringWithFormat:@"http://10.2.176.104:9000/recorddata?id=ios×tamp=%@%%20%@,%%20%@%%20%@&cpu=%@&memory=%@&battery=%@", monthString, dateString, yearString, timeString, self.proData, self.memData,self.batData];
As you can see, I have several local and global variables in the string, along with some percent symbols which I'm escaping with '%'. When I copy and paste this string into Safari in my Simulator, the data gets added to my DB.
I have tried the following code to send the get request via my app:
NSMutableURLRequest *newRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:theGetURL]
cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData
timeoutInterval:10];
[newRequest setHTTPMethod: @"GET"];
NSError *requestError;
NSURLResponse *urlResponse = nil;
NSData *response1 = [NSURLConnection sendSynchronousRequest:newRequest returningResponse:&urlResponse error:&requestError];
NSLog(@"response=%@",response1);
This code compiles and runs fine, but does not work. My DB is still empty.
Any idea what I'm doing wrong?