Abrufen HTTPResponse/HTTPRequest-status-codes in iOS?
Muss ich prüfen und bewerten die HTTP-Status-Codes in meiner iPhone app. Ich habe einen NSURLRequest-Objekt und ein NSURLConnection, die erfolgreich (denke ich) eine Verbindung zu der Website:
//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
}
Ich habe diesen code hier: https://web.archive.org/web/20100908130503/http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html
Aber es funktioniert nicht (so weit ich das sehen kann) sagen nichts über den Zugriff auf den HTTP-Status-codes.
Wie man eine Verbindung zu einer Website, und überprüfen Sie dann die HTTP Status Codes, die Verbindung?
Du musst angemeldet sein, um einen Kommentar abzugeben.
Dies ist, wie ich es mache:
Aber ich bin mit einem asynchronen NSURLConnection, so kann dies nicht helfen. Aber ich hoffe, es funktioniert trotzdem!