• 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
widget plugin crashed when i use thread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

widget plugin crashed when i use thread


  • Subject: widget plugin crashed when i use thread
  • From: Sam Tseng <email@hidden>
  • Date: Tue, 12 Jan 2010 21:51:39 +0800

hi,

i would like to implement a widget plugin to detect iTunes current
artist and current album call back to widget. i ran my widget plugin
in dashcode without crashing. however, i deployed the widget into
dashboard, it crashed all the time. following is part of my codes,
could any one give me hints to tell me which part may cause this
problem. thank you for your help. :)

- (id) initWithWebView:(WebView*)webView
{
	self = [super init];
	iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];
	pTunesRun = TRUE;
	previousdatabaseID = @"";
	[NSThread detachNewThreadSelector:@selector(checkiTunesStatus)
toTarget:self withObject:nil];
	return self;
}

- (void) checkiTunesStatus
{
	NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
	while (pTunesRun) {
		if ([iTunes isRunning]) {
			if ([iTunes playerState] == iTunesEPlSPaused || [iTunes
playerState] == iTunesEPlSStopped) {
				trackInfo = [NSString stringWithFormat: @"%s", "NOT PLAYING"];
			} else {
				if (!iTunes.currentTrack.artist || !iTunes.currentTrack.album)
					trackInfo = [NSString stringWithFormat: @"%@|NULL|NULL",
iTunes.currentTrack.name];
				else if (!iTunes.currentTrack.artist)
					trackInfo = [NSString stringWithFormat: @"%@|%@|NULL",
iTunes.currentTrack.name, iTunes.currentTrack.album];
				else if (!iTunes.currentTrack.album)
					trackInfo = [NSString stringWithFormat: @"%@|NULL|%@",
iTunes.currentTrack.name, iTunes.currentTrack.artist];
				else
					trackInfo = [NSString stringWithFormat: @"%@|%@|%@",
iTunes.currentTrack.name, iTunes.currentTrack.album,
iTunes.currentTrack.artist];
			}
			currentdatabaseID = [NSString stringWithFormat: @"%d",
iTunes.currentTrack.databaseID];
		} else {
			trackInfo = [NSString stringWithFormat: @"%s", "NOT RUNNING"];
		}
		if (autoRefresh) {
			if (![previousdatabaseID isEqualToString: currentdatabaseID]) {
				NSArray* args = [NSArray arrayWithObjects:
								 trackInfo,
								 nil];
				[webScriptObject callWebScriptMethod:@"_updateInfo" withArguments:args];
				previousdatabaseID = [NSString stringWithFormat: @"%@", currentdatabaseID];
			}
		}
		[NSThread sleepForTimeInterval:1.0];
	}
	[pool release];
	[NSThread release];
}

best, sam
_______________________________________________

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: widget plugin crashed when i use thread
      • From: Sam Tseng <email@hidden>
  • Prev by Date: Re: Table object not selected on launch
  • Next by Date: appController class in InterfaceBuilder
  • Previous by thread: Re: Table object not selected on launch
  • Next by thread: Re: widget plugin crashed when i use thread
  • Index(es):
    • Date
    • Thread