Re: Creating a Cocoa Window in code
Re: Creating a Cocoa Window in code
- Subject: Re: Creating a Cocoa Window in code
- From: "Felipe Monteiro de Carvalho" <email@hidden>
- Date: Fri, 18 Jan 2008 12:44:12 +0100
On Jan 18, 2008 12:26 PM, Andrew Farmer <email@hidden> wrote:
> > backing: NSBackingStoreBuffered
> > defer: NO];
>
> Also, this code won't display a window on screen, as there's no runloop.
And how do I get a runloop? I see there is NSApplicationMain, but it
crashes with the code bellow. Also, the docs say it will load the main
nib file, but my project has no nib file.
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[])
{
// Creates an autorelease pool
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
// Loads the application
NSApplicationLoad();
// Creates a simple window
NSRect MainWindowRect = NSMakeRect(300, 300, 300, 500);
id MainWindow = [[NSWindow alloc] initWithContentRect: MainWindowRect
styleMask: NSTitledWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask | NSResizableWindowMask
backing: NSBackingStoreBuffered
defer: NO];
NSApplicationMain(argc, (const char **)argv);
// Call release method from object pool
[pool release];
return 0;
}
--
Felipe Monteiro de Carvalho
_______________________________________________
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