Forum Navigation
You need to log in to create posts and topics.

ToNibOrNotToNib

Posted by: svanvoorst <svanvoorst@...>

<< Nibs are used most of the time in iPhone apps. >>

Bernie,

I'm sure that you have more experience in this area than I do, so I believe you.  I swear I've read this somewhere, but can't come up with the reference.  Maybe in the old days.  There is also a chance that Xcode 4.2.1 makes tighter apps (smaller in size) than what I have seen previously.  I tried to test it by creating the following app in 4.2.1.  I spent all afternoon trying to get everything hooked up and finally made it, but then couldn't find the application.  I was able to "Open in Finder" and do a "Get Info" to determine the size, but never could find the application itself other than inside Xcode.  It is possible that nib based applications now are smaller than what I have been creating in FB.  As time permits, could you please see what results you get, i.e. create a nib based app in 4.2.1 that looks like this demo and report its size.  Thanks.

'------ start ------

BeginCDeclaration
@interface AppController : NSObject
{
}
- (void) myBtnAction:(id)sender;
@end //interface
EndC
BeginCFunction
@implementation AppController
-(void) myBtnAction:(id)sender
{
  NSBeep();
}
@end //implementation
EndC
BeginCCode
{
 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
 [NSApplication sharedApplication];
 [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
// ******** Menu and menubar ********//
  id menubar = [[NSMenu new] autorelease];
  id appMenuItem = [[NSMenuItem new] autorelease];
  [menubar addItem:appMenuItem];
  [NSApp setMainMenu:menubar];
  id appMenu = [[NSMenu new] autorelease];
  id quitMenuItem = [[[NSMenuItem alloc] initWithTitle:@"Quit"
        action:@selector(terminate:) keyEquivalent:@"q"] autorelease];
  [appMenu addItem:quitMenuItem];
  [appMenuItem setSubmenu:appMenu];
    
// ******** Window ******** //
  #define _wndW  300
  #define _wndH  150
  id window = [[NSWindow alloc] initWithContentRect:NSMakeRect( 0, 0, _wndW, _wndH )
        styleMask:NSTitledWindowMask | NSClosableWindowMask
           backing:NSBackingStoreBuffered
               defer:NO];
 [window center];
 [window setTitle:@"Controller_NoNib"];
 [window makeKeyAndOrderFront:nil];
// --- Create an instance of the controller class --- //
id myController = [[AppController alloc]init];
NSButton*btn = [[NSButton alloc]initWithFrame:NSMakeRect( 70, 70, 150, 30 )];
[[window contentView] addSubview: btn];
[btn setBezelStyle:NSRoundedBezelStyle ];
[btn setTitle: @"Beep" ];
[btn setTarget:myController];
[btn setAction:@selector(myBtnAction:)];
[btn release];
// ***** Quit btn ***** //
 NSButton *quitBtn = [[NSButton alloc]initWithFrame:NSMakeRect( _wndW - 130, 30, 95, 30 )];
 [quitBtn setBezelStyle:NSRoundedBezelStyle ];
 [quitBtn setTitle: @"Quit" ];
 [quitBtn setAction:@selector(terminate:)];
 [[window contentView] addSubview: quitBtn];
 [quitBtn release];
[NSApp activateIgnoringOtherApps:YES];
[NSApp run];
[myController release];
[pool drain];
}
EndC
'----- end -----

Steve Van Voorst


To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]