Skip to content

Instantly share code, notes, and snippets.

@yene
Created April 27, 2011 15:50
Show Gist options
  • Save yene/944523 to your computer and use it in GitHub Desktop.
Save yene/944523 to your computer and use it in GitHub Desktop.
loading nib and obtaining ref to the nswindow, all in code
NSMutableArray* topLevelObjs = [NSMutableArray array];
NSDictionary* nameTable = [NSDictionary dictionaryWithObjectsAndKeys:self, NSNibOwner, topLevelObjs, NSNibTopLevelObjects, nil];
if (![[NSBundle mainBundle] loadNibFile:@"bla" externalNameTable:nameTable withZone:nil]) {
NSLog(@"trouble loading bla.xib");
return;
}
for (id object in topLevelObjs) {
if ([object isKindOfClass:[NSWindow class]]) {
[object makeKeyAndOrderFront:nil];
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment