In this code poll from within my app for a reachable network ("http://soxxx9.cafe24.com/event.php")
NSString * szURL =[NSString stringWithFormat:@"http://soxxx9.cafe24.com/event.php"];
NSURL *url = [NSURL URLWithString:[szURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding ]];
NSString *strData;
while(1)
{
NSError *error = nil;
strData = [NSString stringWithContentsOfURL:url
encoding:NSUTF8StringEncoding
error:&error];
if(!error)
break;
//String data is not owned by me, no need to release
}
If you have a better way, please teach me.
You should a class to handle the connection for you. This way you have more control of what's going on with it.
MKNetworkKit
is a solution, you can check it here.