Wie kann ich Daten aus der URL auf dem iPhone?

Bin ich mit dem code aus dem Apple-Dokument, um einige der HTTP-Kommunikation. Ich kann eine Verbindung zu der URL erfolgreich, aber ich konnte nicht empfangen von Daten von meinem server.

//create the request
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://..."]
                        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
    NSMutableData *receivedData=[[NSMutableData data] retain];
} else {
    //inform the user that the download could not be made
}

Kann der Grund dafür sein:

  1. Ich erkläre receivedData in der Aktion selbst. Die Anmerkung sagt, ich soll es erklären anderswo. Wo soll ich es erklären? Sollte ich es erklären, wie controller-Eigenschaft?

  2. Wie kann [[NSMutableData data] retain] finden Sie die URL, wie ist es außerhalb der if{}?

InformationsquelleAutor Chilly Zhong | 2009-02-27
Schreibe einen Kommentar