• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Creating a Cocoa Window in code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Creating a Cocoa Window in code
      • From: Michael Watson <email@hidden>
    • Re: Creating a Cocoa Window in code
      • From: "Felipe Monteiro de Carvalho" <email@hidden>
References: 
 >Creating a Cocoa Window in code (From: "Felipe Monteiro de Carvalho" <email@hidden>)

  • Prev by Date: Re: Creating a Cocoa Window in code
  • Next by Date: Core Data & Bindings, [_NSStateMarker intValue] error
  • Previous by thread: Re: Creating a Cocoa Window in code
  • Next by thread: Re: Creating a Cocoa Window in code
  • Index(es):
    • Date
    • Thread