在此代码中,从我的应用程序中查询可访问网络(“ 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
}
如果你有更好的方法,请教我。