Ok, so I have the NSURLRequest in my main method ( included snippet of my code ) so what your saying is if I delegate the NSURLRequest to a NSRunLoop it will clean it's self up?

Thanks, sorry this is my first hack at something like this :-)

- Charles


int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
        NSError *error;
        
        // Download the tasks xml file
NSURL *tasksUrl = [NSURL URLWithString:@"https://myhost/static/tasks.xml "];
        NSURLResponse *response;
        NSURLRequest *req = [[NSURLRequest alloc] initWithURL:tasksUrl];
NSData *dat = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&error];
        
        // -1203 is a Bad Cert Code     
        if ([error code] == -1203) {
                NSLog(@"Using Unsigned Cert");
[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[tasksUrl host]];
                NSURLRequest *req2 = [[NSURLRequest alloc] 
initWithURL:tasksUrl];
dat = [NSURLConnection sendSynchronousRequest:req2 returningResponse:&response error:&error]; //NSString *urlContent = [[[NSString alloc] initWithData:dat encoding:NSISOLatin1StringEncoding] autorelease];
                //NSLog(@"%@",urlContent);
                if (error) {
                        NSLog(@"%@",error);
                        return 1;
                }
                //[urlContent release];
                [req2 release];
        } else {
                NSLog(@"%@",error);   
                return 1;
        }
        
NSXMLDocument *xmlDoc = [[NSXMLDocument alloc] initWithData:dat options:NSXMLDocumentTidyXML error:&error];
        if (error) {
                NSLog(@"Error: %@",error);
        } else {
                //NSLog(@"%@",xmlDoc);
        }




On Feb 20, 2009, at 10:48 AM, Nick Zitzmann wrote:


On Feb 20, 2009, at 11:30 AM, Charles E. Heizer wrote:

The question/issue I have is my app appears to create separate
threads for different actions such as NSTask, NSURL, NSURLRequest
which is OK. The problem is they don't go away once completed. What
can I do to assure that these methods dont leave these abandon
threads?


NSTask and NSURLRequest work asynchronously using a run loop, and this
sort of thing happens if you are not using a run loop in your thread.
I'd recommend using those classes in the main thread unless you have a
really good reason to be using extra threads.

Nick Zitzmann
<http:// www. chronosnet.com/>





_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to