Question about changing UINavigationItem


#1

On page 206, the book asks you to set the navigationItem’s property to read Homepwner using the following code

self = [super initWithStyle:UITableViewStylePlain]; if (self) { UINavigationItem *navItem = self.navigationItem; navItem.title = @"Homepwner"; }

I was curious as to why the book dosen’t set the property directly like so,

self = [super initWithStyle:UITableViewStylePlain]; if (self) { self.navigationItem.title = @"Homepwner"; }

I built and ran the application using the new code and it work exactly the same. I wanted to know if there is any difference between the two ways of setting the title.


#2

None of any significance.

My guess is that the authors were just trying to be explicit about exactly what type was being returned by self.navigationItem, so the reader could reference the documentation for more info if desired.

You did exactly the right thing: testing your understanding of the code by experimenting with doing it differently.