• 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 unhappiness
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSURLConnection unhappiness


  • Subject: Re: NSURLConnection unhappiness
  • From: Richard Frith-Macdonald <email@hidden>
  • Date: Thu, 30 Apr 2009 07:21:03 +0100


On 30 Apr 2009, at 05:31, Nick Hristov wrote:

Hello,

I am currently working on a small iphone app, and I am facing some
difficulty with getting NSURLConnection to ... connect. Basically my unit
tests don't pass: connection is never made.


Here is a snippet of the non-working code:

<code>

- (id) initWithURL: (NSURL*) someurl
{
self = [super init];
if (self != nil) {
self->url = [someurl copy];
NSURLRequest * request = [NSURLRequest requestWithURL:self->url
cachePolicy: NSURLRequestUseProtocolCachePolicy timeoutInterval: 6.0];
NSLog([NSString stringByAppendingStrings:@"Request: " , [request
description], nil]);
self->finished = NO;
self->connection = [[NSURLConnection alloc]
initWithRequest:request delegate:self startImmediately:NO];
}
return self;
}


- (void) downloadData
{
NSLog([self->connection description]);
NSLog(@"run, b*$#4rd, run...");
[self->connection scheduleInRunLoop:[NSRunLoop currentRunLoop]
forMode:NSDefaultRunLoopMode];
[self->connection start];
int timeout = 30;
int i = 0;
while(self->finished == NO && [self _deletegateTerminateCheck] == NO) {
// suspend thread
[NSThread sleepForTimeInterval: 1.0];

I expect the above line is the problem ... if you suspend the thread then it presumably can't connect to the remote system.
You would probably need to repeatedly run the current runloop using the -runMode:BeforeDate: method instead of suspending the thread.


_______________________________________________

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


References: 
 >NSURLConnection unhappiness (From: Nick Hristov <email@hidden>)

  • Prev by Date: Re: Building a 64-bit Preferences Pane
  • Next by Date: Re: Registering Clients using DO
  • Previous by thread: Re: NSURLConnection unhappiness
  • Next by thread: Re: NSURLConnection unhappiness
  • Index(es):
    • Date
    • Thread