Re: Creating a Cocoa Window in code
Re: Creating a Cocoa Window in code
- Subject: Re: Creating a Cocoa Window in code
- From: Andrew Farmer <email@hidden>
- Date: Fri, 18 Jan 2008 03:26:35 -0800
On 18 Jan 08, at 03:15, Felipe Monteiro de Carvalho wrote:
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:
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?
Compiler warnings are usually correct. When they aren't, it's
generally a good idea to modify your code to avoid them.
id MainWindow = [NSWindow initWithContentRect: MainWindowRect
The NSWindow class does not respond to that selector. Instances of the
NSWindow class do, but you haven't allocated one.
styleMask: NSTitledWindowMask ||
NSClosableWindowMask || NSMiniaturizableWindowMask ||
NSResizableWindowMask
Unrelated to your problem, but you're using the wrong operator here. A
styleMask of 1 won't do you much good.
backing: NSBackingStoreBuffered
defer: NO];
Also, this code won't display a window on screen, as there's no runloop.
I get the sense you may not have worked with Cocoa much before. You
should probably get comfortable with using the framework before you
start trying to do weird things with it.
_______________________________________________
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