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


  • ... Patrick Cardona via Discussion list for the GNUstep programming environment
    • ... Richard Frith-Macdonald
      • ... Patrick Cardona via Discussion list for the GNUstep programming environment
    • ... David Chisnall
      • ... Patrick Cardona via Discussion list for the GNUstep programming environment
      • ... Patrick Cardona
        • ... David Chisnall

Reply via email to