• 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
Creating a Cocoa Window in code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Creating a Cocoa Window in code
      • From: Andrew Farmer <email@hidden>
    • Re: Creating a Cocoa Window in code
      • From: Matt Gough <email@hidden>
  • Prev by Date: Re: new API for MacBook Air for Multi-touch trackpad?
  • Next by Date: Re: Creating a Cocoa Window in code
  • Previous by thread: Re: Conceptually understanding Core Animation
  • Next by thread: Re: Creating a Cocoa Window in code
  • Index(es):
    • Date
    • Thread