• 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: Matt Gough <email@hidden>
  • Date: Fri, 18 Jan 2008 12:23:19 +0100


You are not calling alloc, it should be

id MainWindow = [[NSWindow alloc] initWithContentRect: MainWindowRect etc etc...

Matt

On 18 Jan 2008, at 12:15, Felipe Monteiro de Carvalho wrote:

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 ||
_______________________________________________

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: "Felipe Monteiro de Carvalho" <email@hidden>
References: 
 >Creating a Cocoa Window in code (From: "Felipe Monteiro de Carvalho" <email@hidden>)

  • Prev by Date: Creating a Cocoa Window in code
  • Next by Date: Re: Creating a Cocoa Window in code
  • Previous by thread: Creating a Cocoa Window in code
  • Next by thread: Re: Creating a Cocoa Window in code
  • Index(es):
    • Date
    • Thread