Re: dictionaryWithContentsOfURL Questons
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