troubleshooting Question

NSThread - NSURLConnection

Avatar of eztalk
eztalk asked on
CSwift Programming
2 Comments1 Solution7568 ViewsLast Modified:
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
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros