• 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: Michael Watson <email@hidden>
  • Date: Fri, 18 Jan 2008 07:54:59 -0500

You have "MainMenu" specified for the main nib in the application target.

Also:

  NSApplicationMain(argc, (const char **)argv);

  // Call release method from object pool
  [pool release];

return 0;

It's probably better to do this instead:

  // Call release method from object pool
  [pool release];

  return  NSApplicationMain(argc, (const char **)argv);


-- m-s

On 18 Jan, 2008, at 06:44, Felipe Monteiro de Carvalho wrote:

On Jan 18, 2008 12:26 PM, Andrew Farmer <email@hidden> wrote:
                                backing: NSBackingStoreBuffered
                                  defer: NO];

Also, this code won't display a window on screen, as there's no runloop.

And how do I get a runloop? I see there is NSApplicationMain, but it crashes with the code bellow. Also, the docs say it will load the main nib file, but my project has no nib file.

#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 alloc] initWithContentRect: MainWindowRect
styleMask: NSTitledWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask | NSResizableWindowMask
backing: NSBackingStoreBuffered
defer: NO];


  NSApplicationMain(argc, (const char **)argv);

  // 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:
@bungie.org


This email sent to email@hidden

_______________________________________________

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>)
 >Re: Creating a Cocoa Window in code (From: Andrew Farmer <email@hidden>)
 >Re: 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: Re: Creating a Cocoa Window in code
  • Previous by thread: Re: Creating a Cocoa Window in code
  • Next by thread: Re: Creating a Cocoa Window in code
  • Index(es):
    • Date
    • Thread