Link to home
Start Free TrialLog in
Avatar of eztalk
eztalk

asked on

NSThread - NSURLConnection

i started implement call of getting content from URL, but I get exception
I call
[NSThread detachNewThreadSelector:@selector(loadURL:) toTarget:self withObject:nil];

and then

    - (void)loadURL:(id)param {  
        NSAutoreleasePool* poolL = [[NSAutoreleasePool alloc] init];  
        NSData *data;  
        NSURL *url = [NSURL URLWithString: @"http://www.ya.ru" ];  
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: url  
                                                               cachePolicy: NSURLRequestReloadIgnoringCacheData  
                                                           timeoutInterval: 10];      
        NSURLResponse *response;  
        NSError *error;  
       data = [NSURLConnection  
               sendSynchronousRequest: request  
               returningResponse: &response  
               error: &error];  
       NSString *output = [NSString stringWithCString:[data bytes] length:[data length]];  
       NSLog(@"Page = %@", output);  
       [data release];  
       [url release];  
       [request release];  
       [response release];  
       [error release];  
       [poolL release];  
   }
and get
Program received signal: EXC_BAD_ACCESS.

If I didn't use   poolL
I get many comment on console about leak:

*** _NSAutoreleaseNoPool(): Object 0x457ad0 of class UIAlertView autoreleased with no pool in place - just leaking
Avatar of eztalk
eztalk

ASKER

ASKER CERTIFIED SOLUTION
Avatar of eztalk
eztalk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial