dealloc method error??? Kochan page 180

Discussion in 'Mac Programming' started by mdeh, Jan 13, 2009.

  1. mdeh macrumors 6502

    Joined:
    Jan 3, 2009
    #1
    On p 180 of 2.0, the dealloc method is defined thus.

    Code:
    -(id) dealloc
    {
    	if (origin)
    		[origin release];
    	return [super dealloc];
    }
    Should it not be this?

    Code:
    -(void) dealloc
    {
    	if (origin)
    		[origin release];
    	[super dealloc];
    }

    I think there might also be a misquote on the same page.

    "The dealloc method is defined to return a value of type id. You know this by looking inside the header file <NSObject.h>.....

    NSObject.h shows this though....
    - (void)dealloc;

    Thanks in advance.
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
  3. skochan macrumors regular

    Joined:
    Apr 1, 2006
    Location:
    California
    #3
    Thanks for the catch! Later in the book dealloc is correctly referenced as a void method.

    [The first edition used Object as the root object at this point in the text (and Object.h as the root header file). In that case, the free method, which does return an id object, was the method that was overridden. This didn't do well in the translation to NSObject!]



    Cheers,

    Steve Kochan
     

Share This Page