
I have just made a new update on WorkTimer, which fixes a bug that prevented WorkTimer 2.03 from starting when there was no internet connection. The deal was that I in the previos update did a rather lazy check with no timeout. This caused Worktimer 2.03 to just stagnate when you network was down:
[NSDictionary dictionaryWithContentsOfURL: (NSURL *)internetURL];
The fix
It was easier then I tought, after just 2 min at the great Cocoabuilder.com a found this snipplet that creates a thread that do the internet checking by it self.
The main application thread is left untouched:
- (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];
}