Hi Omar,

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

AUTORELEASE doesn't initialize an object; AUTORELEASE(x) is the same as [x 
autorelease] - so you don't want to send the -autorelease message to an 
uninitialized NSWindow. What you probably want on that line is to call the 
NSWindow initializer, -initWithContentRect:styleMask:backing:defer:.

> 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]?

There is no difference; [x new] is the same as [[x alloc] init].

However, my suggestion is to stick to [x autorelease] and [[x alloc] init] 
instead of AUTORELEASE(x) or [x new].

Hope this helps,

Eric
_______________________________________________
Discuss-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep

Reply via email to