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

Re: dictionaryWithContentsOfURL Questons


  • Subject: Re: dictionaryWithContentsOfURL Questons
  • From: Andrew Zamler-Carhart <email@hidden>
  • Date: Mon, 18 Oct 2004 22:09:39 +0100

The best thing would be to do this in a thread. Here is the code that our apps use for this purpose. This normally times out after ten seconds in my experience.

- (IBAction) checkVersion: (id) sender {
[NSThread detachNewThreadSelector: @selector(checkVersionInThread:)
toTarget: self withObject: sender];
}

- (void) checkVersionInThread: (id) sender {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

NSDictionary *versionDict = [NSDictionary dictionaryWithContentsOfURL: versionsURL];
if (versionDict != nil) {
// do stuff
} else {
NSLog(@"Unable to download version information.");
}

[pool release];
[NSThread exit];
}

On Oct 18, 2004, at 9:21 PM, Kodex wrote:

Hello all. I am using dictionaryWithContentsOfURL to
check for new versions of a program i am working on,
the problem i am having is that if the user does not
have an internet connection the check will hang
forever (or atleast a long period of time). Is there
an easy way to set a timeout for this function? Thank
you for your time as always.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: dictionaryWithContentsOfURL Questons
      • From: Daniel Todd Currie <email@hidden>
References: 
 >dictionaryWithContentsOfURL Questons (From: Kodex <email@hidden>)

  • Prev by Date: Re: Making my transition to bindings, how do I initilize my values & notifications?
  • Next by Date: Fwd: Weak linking constants
  • Previous by thread: dictionaryWithContentsOfURL Questons
  • Next by thread: Re: dictionaryWithContentsOfURL Questons
  • Index(es):
    • Date
    • Thread