Silver Challenge criticisms/concerns


FIrst, I want to say I am really liking the Bronze/Silver/Gold challenge divisions in this 3rd edition of the book, compared to the 2nd edition. They have really been helping to establish my understanding as I go through the chapters.

Up to this point they have been great! But on this chapter there is some ambiguity and a sense of pointlessness to the Silver challenge.

For the Silver challenge having us programmatically set the AutoresizingMask for the subviews of a XIB seems awkward since this view was not created programmatically to begin with. And then it gets strange when I ponder how to distinguish between the two UIButtons on the view in the XIB. Other than trying to use their location in the array returned from the subviews call, which I don’t think should be relied upon in practice since it could change if other views were added. And even then, initially, it would have to be guessed at which UIButton is which.

I looked into the tag property but that is intended to get set when the view is created, again programmatically.

I tried using the Label feature in the Interface Builder but it seems to not be accessible at run-time.

I am just left feeling like it is best to skip this Challenge. I get the premise well enough especially if it had been a programmatically created view to begin with.


Ah, but this is part of the challenge!

You’ll want to set the masks for these buttons in your viewDidLoad method. In order to have reliable pointers to the buttons, you’ll need to create IBOutlets and connect them to the buttons in Interface Builder.


Hehe. :smiley: Thanks for the tips and some guidance! It just isn’t gelling for me conceptually, this mixing programmatic UI with UI done in Interface Builder.

Is there a relevant section in the text on this idea of mixing that I may have missed or misunderstood? I only recall you mentioning that, paraphrased, “…If you are going to have lots of views then use the Interface Builder, if only one or a few do them programmatically…”

Thanks again!

Now it just clicked, that you had us put the controls on the view with Interface Builder but we hadn’t really done anything with them yet in code. Duh. I guess it tripped up my understanding since the UI did so much already with so little it sent me off on the wrong track in my head. I really get what your saying in your response now, thank you! :ugeek:


The details of how a XIB file work are slowly leaked out in later chapters… a little here, a little there, depending on what you have been taught so far. I’m comfortable that by the end of the book, you’ll “get” the XIB file. If not, you can always ask here and I’ll answer. :slight_smile: