I have a php website that returns YES or NO upon request.
For example
http://www.test.com/test.php?variable=test1
will return me YES
and http://www.test.com/test.php?variable=test2
will return me NO
I am trying to get this response into an Objective-C application I am creating but I have no luck up to now.
Here is my code
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.test.com/test.php?variable=test1"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
NSMutableData *receivedData = [NSMutableData data];
NSString *strData = [[NSString alloc]initWithData:receivedData encoding:NSUTF8StringEncoding];
NSLog(@"This is the response: %@", strData);
}else {
}
Can anybody help me on that? is there any other way to do it? Am I doing something wrong?
Thanks a lot guys
If your app targets iOS 5 just use this code to your xxx.m file under the method you create the request. And if you want to use it in some other versions of iOS, Take a look JSON parser frameworks..