28
我需要检查和评估我的iPhone应用程序中的HTTP状态代码。我有一个的NSURLRequest对象和NSURLConnection的是成功地(我认为)连接到站点:检索HTTPResponse/HTTPRequest状态码iPhone SDK?
// create the request
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com/"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
// create the connection with the request
// and start loading the data
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
// Create the NSMutableData that will hold
// the received data
// receivedData is declared as a method instance elsewhere
receivedData=[[NSMutableData data] retain];
} else {
// inform the user that the download could not be made
}
但事实并非如此(只要我能看到)说任何关于访问HTTP状态代码。
任何人都有任何想法如何建立一个网站的连接,然后检查该连接的HTTP状态代码?
在此先感谢!
这确实实现了我所需要的。唯一的问题是,如果URL/IP Addy不存在,则不会收到响应,所以应用程序只会永远挂在那里。我目前正在寻找一种方法来解决这个问题......任何建议,将不胜感激...... – cmcculloh 2009-05-28 15:39:24