discuss-gnustep
[Top][All Lists]
Advanced

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

Re: Tutorials enhancement proposal : First Steps in GNUstep GUI Programm


From: Richard Frith-Macdonald
Subject: Re: Tutorials enhancement proposal : First Steps in GNUstep GUI Programming (2) : NSWindow, NSButton
Date: Wed, 10 Jun 2020 11:04:11 +0100


> On 10 Jun 2020, at 10:42, Patrick Cardona via Discussion list for the GNUstep 
> programming environment <discuss-gnustep@gnu.org> wrote:
> 

> (2) In the method 'createWindow' :
> 
> - (void) createWindow
> {
> ...
> myWindow = [NSWindow alloc];
> 
>  /* Don't make a assignment of 'myWindow' again...
>  myWindow = */
>  /* So I kept only the message... */
>  [myWindow initWithContentRect: rect
>                       styleMask: styleMask
>                       backing: NSBackingStoreBuffered
>                       defer: NO];

The correct code here is

myWindow = [NSWindow alloc];
myWindow = [myWindow initWithContentRect: rect
                      styleMask: styleMask
                      backing: NSBackingStoreBuffered
                      defer: NO];

You *must* have the second assignment, because the initWithContentRect:... 
method may destroy the original window and return a new one.  maybe it would 
help for the tutorial to have a comment saying that.

If you find it aesthetically displeasing to have two assignments, you can write 
the code as

myWindow = [[NSWindow alloc] initWithContentRect: rect
                      styleMask: styleMask
                      backing: NSBackingStoreBuffered
                      defer: NO];




reply via email to

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