Skip navigation.
 
mlNSURLRequest : Unable to Quit App after Syn call to Server.
FROM : fclee
DATE : Thu May 15 23:21:38 2008

Greetings:
    The Cocoa code below "works".  I get data back from the server.  However, I'm unable to QUIT this application after this particular routine passes through.  I checked the Activity Monitor and can see a bunch of threads still in session:

Call graph:
    1922 Thread_2503
      1922 start
        1922 main
          1922 NSApplicationMain
            1922 -[NSApplication run]
              1922 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]
                1922 _DPSNextEvent
                  1922 BlockUntilNextEventMatchingListInMode
                    1922 ReceiveNextEventCommon
                      1922 RunCurrentEventLoopInMode
                        1922 CFRunLoopRunInMode
                          1922 CFRunLoopRunSpecific
                            1922 mach_msg
                              1922 mach_msg_trap
                                1922 mach_msg_trap
    1922 Thread_2603
      1922 thread_start
        1922 _pthread_start
..
..
'
===================================

It's supposed to be SYNCHRONOUS (get data one-time & exit).  Yet I see threads dangling.
Question: How can I safely END this routine? 

Code follows:
-----------------


- (IBAction)startSOAP:(id)sender {
    NSError **myError;
    NSHTTPURLResponse **serverResponse;
    NSData *serverData;

    @try {
       
        // 1) The Request String.  {not used yet}
        // Note: smsXMLString contains the entire SMS SOAP envelope, without the <? XML declaration command >.
        NSString *smsXMLPath = [[NSBundle mainBundle] pathForResource:@"sms" ofType:@"xml"];
        self.smsXMLString = [NSString stringWithContentsOfFile:smsXMLPath encoding:NSUTF8StringEncoding error:myError];

        // -----------------------
        // 2)  Create the request.
        NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:theServerURL]
                                                  cachePolicy:NSURLRequestUseProtocolCachePolicy
                                              timeoutInterval:10.0];

        // -----------------------
        // 3)  Get Synchronous Data:       
        serverData = [NSURLConnection sendSynchronousRequest:theRequest
                                                                  returningResponse:serverResponse
                                                                  error:myError];

        // -----------------------
        // 4)  Convert Synchronous Data into Human-Readable String (Unicode 8) format:       
        NSString *serverDataString = [[[NSString alloc] initWithData:serverData encoding:NSUTF8StringEncoding] retain];

        [[soapResponse layoutManager]replaceTextStorage:[[NSTextStorage alloc] initWithString:serverDataString]];
       
        [serverDataString release];
       
    } @catch (id e) {
        NSLog(@"\n**** EXCEPTION: %@ ****\n",e);
        self.statusLine.stringValue = [NSString stringWithFormat:@"*** Exception flagged: %@ ***",e];
    } @finally {

        NSLog(@"\n end.");
    }
     
       
} // end startSOAP().

// -----------------------------------------------

- (IBAction)terminateSOAP:(id)sender {
    NSLog(@"\n GoodBye.\n");
    [NSApp stop:self];    // <-------- Does not work when above routine was performed.
}

-------

Regards,
Ric.

Related mailsAuthorDate
mlNSURLRequest : Unable to Quit App after Syn call to Server. fclee May 15, 23:21
mlRe: NSURLRequest : Unable to Quit App after Syn call to Server. Jens Alfke May 16, 02:56
mlRe: NSURLRequest : Unable to Quit App after Syn call to Server. fclee May 16, 15:32
mlRe: NSURLRequest : Unable to Quit App after Syn call to Server. stephen joseph but… May 16, 16:53
mlRe: NSURLRequest : Unable to Quit App after Syn call to Server. Frederick C. Lee May 17, 20:58
mlRe: NSURLRequest : Unable to Quit App after Syn call to Server. Dominik Pich May 17, 21:23