NSURLConnection méthode déléguée n'est pas appelé (didReceiveResponse, connectionDidFinishLoading etc) .Lorsque je suis en utilisant une même méthode de délégué de classe appelée correctementproblème NSURLConnection Les délégués
category *cat = [[category alloc]init];
[cat getcategory:@"1088"];
dans une page de catégorie
(void) getcategory: (NSString *) catid {
[...]
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:urlrequest delegate:self];
NSHTTPURLResponse *response;
[NSURLConnection sendSynchronousRequest: urlrequest returningResponse: &response error: nil];
if(theConnection)
{
webData = [[NSMutableData data] retain];
}
else
{
NSLog(@"theConnection is NULL");
}
}
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
[webData setLength: 0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[webData appendData:data];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
NSLog(@"ERROR with theConenction");
[connection release];
[webData release];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSLog(@"DONE. Received Bytes: %d", [webData length]);
NSString *theXML = [[NSString alloc] initWithBytes: [webData mutableBytes] length: [webData length] encoding:NSUTF8StringEncoding];
}
que voulez-vous dire par: "lorsque j'utilise une même méthode de délégation de classe appelée correctement"? – sergio
je mets en œuvre un code dans les délégués de même classe fonctionnant correctement – Rams