• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSURLRequest : Unable to Quit App after Syn call to Server.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSURLRequest : Unable to Quit App after Syn call to Server.


  • Subject: NSURLRequest : Unable to Quit App after Syn call to Server.
  • From: email@hidden
  • Date: Thu, 15 May 2008 14:21:38 -0700 (PDT)

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**** {startSOAP} EXCEPTION: %@ ****\n",e);
        self.statusLine.stringValue = [NSString stringWithFormat:@"*** Exception flagged: %@ ***",e];
    } @finally {

        NSLog(@"\n{startSoap} end.");
    }


} // end startSOAP().

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

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

-------

Regards,
Ric.

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSURLRequest : Unable to Quit App after Syn call to Server.
      • From: "stephen joseph butler" <email@hidden>
    • Re: NSURLRequest : Unable to Quit App after Syn call to Server.
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: Using NSThreads in command-line apps
  • Next by Date: Re: NSDictionaryController with NSTableView and sorting of numeric data
  • Previous by thread: Re: Using NSThreads in command-line apps
  • Next by thread: Re: NSURLRequest : Unable to Quit App after Syn call to Server.
  • Index(es):
    • Date
    • Thread