small medium large xlarge

30 Dec 2009, 12:00
Andrew Greaney (4 posts)

On page 138 (Implementing the Loading of the Previous Page) the code is [self.myWebView goBack:sender];

What is the purpose of self? (as the code works fine without it)

30 Dec 2009, 14:59
Daniel H Steinberg (97 posts)

You are accessing the underlying instance variable directly. In this case there are probably no ill effects but it’s not a good idea. In general we want to be able to take advantage of memory management or allow for lazy initializers or other similar things that we’ll accomplish in the accessors that aren’t provided by the ivar.

You are (I assume) calling [myWebView goBack:sender] and I’m essentially calling [ [ self myWebView] goBack:sender]. i.e. I’m using the getter.

You must be logged in to comment