Creating a Cocoa Window in code
Creating a Cocoa Window in code
- Subject: Creating a Cocoa Window in code
- From: "Felipe Monteiro de Carvalho" <email@hidden>
- Date: Fri, 18 Jan 2008 12:15:08 +0100
Hello,
I am trying to implement a new backend for a cross-platform GUI
library using Cocoa, and for that I am trying to create a simple
window using purely code. I read the docs and I see that I should
create a NSWindow:
http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindow_Class/Reference/Reference.html#//apple_ref/occ/instm/NSWindow/initWithContentRect:styleMask:backing:defer:
I created a simple application which should just create a simple
window, but it crashes on startup. Xcode warns that NSWindow may not
respond to the initWithContentRect message, but according to the docs
it should. Any ideas what is missing to make this work?
thanks, here is my initial code:
#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 initWithContentRect: MainWindowRect
styleMask: NSTitledWindowMask ||
NSClosableWindowMask || NSMiniaturizableWindowMask ||
NSResizableWindowMask
backing: NSBackingStoreBuffered
defer: NO];
// 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