• 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
NSWindowController and nib in framework
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSWindowController and nib in framework


  • Subject: NSWindowController and nib in framework
  • From: Quincey Morris <email@hidden>
  • Date: Tue, 25 Sep 2012 19:35:13 -0700

Here's an except of some code in a window controller:

> - (id) init {
> 	self = [super initWithWindowNibName: @"MyWindow"];
> 	…
> 	return self;
> }
>
> + (MyWinController*) myWinController {
> 	return [[MyWinController alloc] init];
> }

The key point here is that the MyWinController class, and the MyWindow nib file, are both in a private framework, hence not in the main bundle.

On some Macs (10.7 and 10.8) this throws an exception some of the time:

> 9/25/12 6:39:49.700 PM MyApp[1040]: -[MyWinController loadWindow]: failed to load window nib file 'MyWindow'.

According to the documentation, the window controller initWithWindowNibName should try to find the nib file in [NSBundle bundleForClass: [self class]], but this was apparently returning nil. When I logged this expression, the problem vanished. It seems that referencing (creating?) the NSBundle object was enough to make the window control init work. That is, this alternative:

> + (MyWinController*) myWinController {
> 	[NSBundle bundleForClass: [self class]];
> 	return [[MyWinController alloc] init];
> }

seems to fix the problem. Anyone have an idea what's going on here, and what I should really do to avoid/fix the problem?




_______________________________________________

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: NSWindowController and nib in framework
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: drawGlyphsForGlyphRange layout issue
  • Next by Date: Core Data - nil-ing a relationship to a missing object
  • Previous by thread: Just to confirm: no way to get/set wifi programmatically on iOS, right?
  • Next by thread: Re: NSWindowController and nib in framework
  • Index(es):
    • Date
    • Thread