[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question about object initialization and autorelease

From: Omar Campos
Subject: Question about object initialization and autorelease
Date: Fri, 30 Mar 2012 16:35:28 -0400

Hi all,

I've been reading the tutorials at http://www.gnustep.it/nicola/Tutorials/ and trying them out from memory, but using ProjectCenter instead of manually creating the GNUMakefile.  When running my app, I kept getting an illegal operation.  Upon closer inspection, I found the problem to be the following line:

mainWnd = AUTORELEASE([NSWindow alloc]);

mainWnd is a NSWindow* object declared in my AppController.h.  When called from applicationWillFinishLaunching:, the line above caused an illegal operation. After removing the call to the AUTORELEASE() macro, it worked. Calling AUTORELEASE worked fine when adding an NSMenu* object to the app.  The question is: when should I initialize an object with AUTORELEASE, and when shouldn't I?

Also, coming from a iOS background, I am used to seeing [[objectClass alloc] init] for initialization, yet in GNUStep, it is done with [new].  What's the difference? Or when should I use [[alloc] init]?

Thx for any info!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]