06 May 2010

Why assign a pointer to nil, then to something else?

I'm wondering if there is a typo on page 141 of the text where these two lines of code appear:

newCity.cityPicture = nil;
newCity.cityPicture = cityPicture;

Isn't the first assignment statement irrelevant since it is overwritten anyway on the next line? Or does assigning a pointer to nil have a side affect? (I say a pointer because each City object has a pointer of type UIImage named "cityPicture". ) I think Chen may have spotted this first, but I wanted to put it on the blog.

3 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. Dang, we've been spammed! Anyway, yeah, I think the assignment to nil is another typo, or maybe a leftover from an earlier version of the exercise.

    ReplyDelete
  3. We're serious about increasing your sales. blackberry app developers
    mobile website development

    ReplyDelete