• 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
Multiple instances of NSApp/NSApplicationLoad()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Multiple instances of NSApp/NSApplicationLoad()


  • Subject: Multiple instances of NSApp/NSApplicationLoad()
  • From: Kevin Walzer <email@hidden>
  • Date: Tue, 17 Feb 2009 08:26:08 -0500
  • Organization: WordTech Communications LLC

I'm trying to write a dylib extension to the Tcl/Tk scripting language that updates an application icon with a call to [NSApp setApplicationIconImage]. My code works as expected until it is time for me to restore the original application icon. At that point my app quits with this error:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Creating more than one Application'

I have multiple calls to NSApp, which is apparently the problem--I am not correctly setting the NSApp global. I've been advised to call NSApplicationLoad(), since Tcl/Tk is currently based on Carbon, but I'm not sure where to do this.

The relevant code is below. Any advice is appreciated. --Kevin

--
#import "cocoadock.h"

@implementation CocoaDock

// cocoa command to set the dock icon.

-(int) switchIcon: (NSString *) iconPath  {


	//set up autorelease pool
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

      //convert file path to URL
     iconURL = [[NSURL alloc] initFileURLWithPath: iconPath];

    //create image from URL
     newIcon = [[NSImage alloc] initWithContentsOfURL: iconURL];

	//set the new icon
     [NSApp setApplicationIconImage: newIcon];

    //release the memory
     [newIcon release];
	 [iconURL release];

	 [pool release];		

 	return 0;
}


-(int) origIcon { //set up autorelease pool NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

	//restore the app icon
    [NSApp setApplicationIconImage:nil];

     [pool release];

     return 0;

}


@end

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
_______________________________________________

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: Multiple instances of NSApp/NSApplicationLoad()
      • From: Kevin Walzer <email@hidden>
  • Prev by Date: Re: [iPhone] Abort/remove all running/pending animations [SOLVED]
  • Next by Date: Re: QTMovie brief pause
  • Previous by thread: Re: At what point during loading can NSPersistentDocument fetch?
  • Next by thread: Re: Multiple instances of NSApp/NSApplicationLoad()
  • Index(es):
    • Date
    • Thread