• 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: "Felipe Monteiro de Carvalho" <email@hidden>
  • Date: Fri, 18 Jan 2008 12:44:12 +0100

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Creating a Cocoa Window in code
      • From: Michael Watson <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>)

  • Prev by Date: Core Data & Bindings, [_NSStateMarker intValue] error
  • 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