• 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
Re: NSURLConnection problem on Mac OS X 10.7
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSURLConnection problem on Mac OS X 10.7


  • Subject: Re: NSURLConnection problem on Mac OS X 10.7
  • From: Mike Abdullah <email@hidden>
  • Date: Thu, 08 Sep 2011 10:46:35 +0100

On 7 Sep 2011, at 14:37, Payal Mundhada wrote:

> Hi Mike,
>
>  I am creating request as follows:
>
> @implementation WebService
> -(void)makeRequest
> {
>                   m_URLRequest= [NSMutableURLRequest requestWithURL:url];
>                   [m_URLRequest setHTTPMethod:@"POST"];
>                   [m_URLRequest addValue:SOAPACTION_ISSERVICEAVAILABLE forHTTPHeaderField:@"SOAPAction"];
>                   [m_URLRequest addValue:CONTENTTYPE forHTTPHeaderField:@"Content-Type"];
>                   [m_URLRequest setHTTPBody:[REQUEST_ISSERVICEAVAILABLE dataUsingEncoding:NSUTF8StringEncoding]];
>
>                   m_connection =[[NSURLConnection alloc]initWithRequest:m_URLRequest delegate:self];
>
>                   m_runLoop =[NSRunLoop currentRunLoop];
>                   m_runLoopRef =[m_runLoop getCFRunLoop];
>       if(m_connection!=nil)
>             {
>                   m_receivedData=[[NSMutableData data] retain];
>                   CFRunLoopRun();
>             }
> }
>
> In delegate connectionDidFinishLoading handling as follows:
> -(void)connectionDidFinishLoading:(NSURLConnection *)connection
> {
>       @try {
>             CFRunLoopStop(m_runLoopRef);
>             [m_connection release];
>             m_connection =nil;
>       }
> }
> -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
> {
>                         [m_receivedData setLength:0];
>             NSHTTPURLResponse *urlResponse=(NSHTTPURLResponse*)response;
>             NSString *str_response=[NSHTTPURLResponse localizedStringForStatusCode:[urlResponse statusCode]];
>
>             NSLog(@"%@", str_response);
>
>             NSLog(@"%@", [urlResponse allHeaderFields]);
>             if([urlResponse statusCode]> 200)
>             {
>                   [m_receivedData release];
>                   m_receivedData =nil;
>                   NSLog(@"%@",str_response);
>             }
> }
> @end

What made you decide to write this code in the first place? NSURLConnections are intended to be asynchronous. You're trying to force it to be synchronous in a way that I suspect Cocoa doesn't expect.

_______________________________________________

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: NSURLConnection problem on Mac OS X 10.7
      • From: Jens Alfke <email@hidden>
References: 
 >Fwd: NSURLConnection problem on Mac OS X 10.7 (From: Payal Mundhada <email@hidden>)
 >Re: NSURLConnection problem on Mac OS X 10.7 (From: Mike Abdullah <email@hidden>)

  • Prev by Date: [ANN] AMRollOverButton for Lion
  • Next by Date: NSOutlineView and -reloadDataForRowIndexes:columnIndexes:
  • Previous by thread: Re: NSURLConnection problem on Mac OS X 10.7
  • Next by thread: Re: NSURLConnection problem on Mac OS X 10.7
  • Index(es):
    • Date
    • Thread