Amazon.com Widgets Possible typo on page 167
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 21, 2013, 11:33:36 AM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Programming in Objective-C, 4th edition
| |-+  Chapter 8
| | |-+  Possible typo on page 167
Pages: [1]   Go Down
Print
Author Topic: Possible typo on page 167  (Read 78 times)
todrico
Newbie
*
Posts: 17


Email




« on: March 13, 2013, 10:05:24 AM »


Code: (Objective-C)
-(void) setOrigin: (XYPoint *) pt  

    if (! origin) 
        origin = [[XYPoint alloc] init];     
    origin.x = pt.x;                             
    origin.y = pt.y;                             

The book states on page 167, "If the origin is zero, the setOrigin: method will allocate and initialize a new XYPoint object and store the reference to it in the origin." If origin is zero then it is not pointing to anything and why perform an allocation of origin if it is zero. Should it not read as " If the origin is not zero" which means origin is already pointing to a value and a new instance of this object needs to be allocated. Am I reading this wrong?
Logged
Pages: [1]   Go Up
Print
Jump to:  



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.