• 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
How do I load resources from NSBundle correctly?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How do I load resources from NSBundle correctly?


  • Subject: How do I load resources from NSBundle correctly?
  • From: Gore <email@hidden>
  • Date: Sat, 24 Nov 2001 16:46:43 +0200

What should I do to load the resources inside a bundle in a correct way ? here is what I do right now, this code is inside my NSDocument class, used to load the interface for my plugins, but if I open a new document and try to load it again, it gives me the "Error in loading interface." error, hmm...please help, newID is a class instance in my NSDocument.

- (IBAction)runPluginWithMenu:(id)sender // sender is a NSMenuItem from the plugin menu
{
NSBundle *thePlugin = [NSBundle bundleWithPath:
[[[NSBundle mainBundle] builtInPlugInsPath] stringByAppendingFormat: @"/%@.bundle", [sender title]]];

currentPluginName = [sender title]; // save the name for later use

if ( runningPlugin == NO ) // just to be safe...so that you can't run many plugins at the same time
{
if ( [thePlugin load] )
{
newID = [[[thePlugin principalClass] alloc] init];

[newID setCurrentDocument: self]; // give the plugin instance the current document to play with

if ( [newID pluginIsGUI] ) // if YES, then load the resources
{
if ( [NSBundle loadNibNamed: @"PluginInterface" owner: newID] ) // should the owner be a class or instance!?
{
[pluginBox setContentView: [newID pluginView]];

runningPlugin = YES;

[NSApp beginSheet: pluginsPanel modalForWindow: docWindow
modalDelegate: self didEndSelector: NULL contextInfo: nil];
}
else
NSRunAlertPanel( [sender title], @"Error in loading interface.", @"OK", nil, nil );
}
else
{
runningPlugin = YES;
[self runThePlugin: self];
}
}
else
NSRunAlertPanel( [sender title], @"Error in loading plugin.", @"OK", nil, nil );
}
}


  • Follow-Ups:
    • Re: How do I load resources from NSBundle correctly?
      • From: Ondra Cada <email@hidden>
  • Prev by Date: How do I load NSBundle in a correct way?
  • Next by Date: Re: How do I load NSBundle in a correct way?
  • Previous by thread: Re: How do I load NSBundle in a correct way?
  • Next by thread: Re: How do I load resources from NSBundle correctly?
  • Index(es):
    • Date
    • Thread