Como posso receber dados de URL no iPhone?
Estou usando o código do documento da Apple para fazer alguma comunicação HTTP. Posso conectar-me ao URL com êxito, mas não recebi os dados do meu servidor.
// 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
}
O motivo pode ser:
Eu declaroreceivedData
na própria ação. A anotação diz que eu devo declarar em outro lugar. Onde devo declarar? Devo declarar como propriedade do controlador?
Como pode[[NSMutableData data] retain]
encontre o URL, pois está fora doif{}
?