Generic-user-small Aneurin Bark... 4 posts

Hi,

I’m a student at Bournemouth Media School attempting to learn to develop for the iPhone and had no luck even getting my head around the basics until I found this PDF, so up to 3.11 all was well. But then:

Our AddTeamViewController views needs a title and a button to get back
to the list of teams. Search for “Navigation Item” in the Inter face Builder
library. Drag an instance into our AddTeamViewController Inspector win-
dow. Control click the File’s Owner to the “Navigation Item” and assign
it to the File’s Owner’s navigationItem outlet. Then set the title of the
Navigation Item to “Add Team” in the attribute inspector.

I don’t have a navigationItem outlet, nor was I told to create one?.. I don’t really understand where to go from here. I can’t progress, and I can’t find anything related when I backtrack.

Any input appreciated.

Thanks,
Aneurin

 
Photo_13_small Bill Dudney 372 posts

Hi Aneurin,

navigationItem is inherited from UIViewController so you do have it despite not creating it yourself.

Please post back if this does not make sense.

Thanks for the kind words about the book.

 
Generic-user-small Aneurin Bark... 4 posts

Hi again,

Thanks for the response… but I actually suspected that at first, yet could not find such an outlet.

I’ve just opened up Interface Builder again to see and accidentally ctrl-clicked File’s Owner (the Editor nib as per tutorial 3) to find navigationItem sitting right there waiting to be connected up!

http://img380.imageshack.us/img380/1584/picture1so3.png

Ctrl-click-dragging to the Navigation Item I dragged to the nib didn’t show navigationItem before… but it does now. Crazy!

I’m in an awkward position right now as I’m forced to put my Macbook on the windowsill in order to get within the wireless network range, but I’ll try to complete the tutorial as soon as I’m able to move back to my usual location.

Much appreciated!

 
Generic-user-small Han-Shen Yuan 2 posts

I think this section is problematic and I’d like to add some feedback as I too had problems with this specific area:

“Our AddTeamViewController views needs a title and a button to get back
to the list of teams. Search for “Navigation Item” in the Inter face Builder
library. Drag an instance into our AddTeamViewController Inspector win-
dow. Control click the File’s Owner to the “Navigation Item” and assign
it to the File’s Owner’s navigationItem outlet. Then set the title of the
Navigation Item to “Add Team” in the attribute inspector.

The confusing part here is “Drag an instance into our AddTeamViewController Inspector window…” – the inspector window is the one with the 4 panels on it and I don’t think you meant to drag the control to that did you? (For the life of me, I can’t get that to work). I did however, drag the item to the .xib window and placed the item hierarchically underneath the view whose name is still called “view” at this point in the reading since you have not instructed to name it anything otherwise.

Now, if you do all of this, guess what? Ctrl-clicking the item back and forth between the items yields no such outlets nor has the File’s owner been associated with a class which is what Anuerin first discovered. He must have gone ahead anyways to 3.12 and later discovered after the fact that the outlet appeared (after assosciating the view in the nib file to the controller)

I suspect this can be resolved after we create the class, set the File’s owner of nib file to the right class and then hook it up as you described in 3.12 but working through the instructions verbatim and then going backwards, I think this will work.

Your response Aneurin talks about how UIViewController has a navigationItem but the class isn’t even created till section 3.12 and the AddTeamViewController isn’t hooked up until that section either. I think what needs to happen is that a stub of the class described in sections 3.12 needs to appear first, then talk about the work in 3.11…

 
Generic-user-small Han-Shen Yuan 2 posts

I’ve gone through the section now and pretty much confirmed this is the case in the text. I think the first paragraph in section 3.12 would be a good place to put the offending paragraph. You’re discussing several linkages in that paragraph so you might as well connect up the navigationItem association there as well.

While I am at it, I do have other thoughts on the book.

It wasn’t clear from the preface but I think a reader pretty much needs a firm grounding in OO programming, as well as a passing familiarity with Objective C to really sink their teeth into the book. Otherwise, the reader is left with the feeling that they are mostly typing in what the examples tell them to. I even had to read portions of the Interface Builder manual because I did not understand the outlet/action paradigm. The chapters that introduce the outlet/action paradigm tell the reader to ctrl-drag various things together without really explaining why two things are being dragged in the direction they are (why not the reverse?).

So, I think the the text either needs to be bolstered in these areas or several of the Apple documents should be recommended as prerequisites. Another example is that the text on the one hand assumes that the reader has never seen XCode but on occasion refers the reader to the documentation, yet I don’t recall the API discussion being mentioned anywhere. Higher calibur programmers will naturally find additional information in the form of Apple documents and Google for the answers they don’t know, but I would think the goal of the book is to minimize this. I am finding that I am doing this more often for this book than any other Pragmatic Programmers text I have purchased to date (and I have purchased other beta books as well). Perhaps I did not meet the pre-requisites but if so, I think this needs to be stated then.

 
Generic-user-small Aneurin Bark... 4 posts

I’m glad I’m not the only one that found 3.11 to be peppered with pitfalls! However, I should correct my second post in this topic; it was not the Editor nib, as I had the wrong project open, but the AddTeamViewController nib (if I recall the name correctly). I have corrected it and completed the tutorial since my last post. However, no navigationItem outlet was present at first. This was perhaps because, as Han-Shen suggested, there was no indication that the view should take the class AddTeamViewController (again IIRC) as opposed to the default UIViewController. I had not yet assigned the view to any @interface in Xcode. Perhaps it was assumed that I would do this beforehand, as it was discussed in Chapter 2, but as a total newcomer to Obj-C and Cocoa this didn’t seem obvious. I have plenty of experience in OOP but am wholly unused to visual interfaces.

I also feel navigationItem should be explained as deriving from UIViewController, rather than being a user defined outlet, as it was not otherwise obvious to me before reading Bill’s post above.

Other than those specific quirks, though, these tutorials have been most helpful. I’ve only moaned so far, but keep up the good work; I look forward to and will recommend the final version when it’s out, if it’s at least as helpful as this beta!

 
Photo_13_small Bill Dudney 372 posts

Thanks Everyone for the great feedback! We will be addressing this stuff in a future beta. No promise on the exact date but soon.

 
Davide-inis-meann_small Davide Benini 1 post

For those rereading this point, a brief summary on how to solve the problem:

This part:

“Our AddTeamViewController views needs a title and a button to get back
to the list of teams. Search for “Navigation Item” in the Inter face Builder
library. Drag an instance into our AddTeamViewController Inspector win-
dow. Control click the File’s Owner to the “Navigation Item” and assign
it to the File’s Owner’s navigationItem outlet. Then set the title of the
Navigation Item to “Add Team” in the attribute inspector.” (in 3.11)

Must be done after this part:

“All connections are done in Inter face Builder so go back to IB and in the AddTeamViewController object inspector window click on File’s Owner. Over in the Attributes inspector (press Command – 1 if you can’t find it on your screen), if we click on the Identity tab (it’s the rightmost), we’ll
notice that File’s Owner’s class is set to NSObject. Since this is the interface for the AddTeamViewController we want to change File’s Owner’s class to that.” (first operation to do in 3.12)

Otherwise it won’t work.

Davide

 
Lm6ab89b69485d2bc653e91205737bcc7f_dsc00211_small Robert Mirabito 14 posts

Bill, there is a typo on page 61 of this section as well. In paragraph 4 where you create the new UIViewController subclass.

In Xcode select File->New File… (or Command – N ). When propmted choose a UIViewController subclass that we’re going to call addTeamViewController.

As you can see, propmted should be prompted.

 
Photo_13_small Bill Dudney 372 posts

Thanks Robert!

Would you mind filing this as an errata here;

http://www.pragprog.com/titles/amiphd/errata

Thanks!

 
Generic-user-small Martin Stanhope 2 posts

I would have hit a brick wall unless I had spotted this thread of the forum. Following Davide’s suggestion did the trick. I would suggest that amending sections 3.11 & 3.12 is fairly urgent as it will block people following the book.

Martin

 
Photo_13_small Bill Dudney 372 posts

Hi Martin,

Thanks for the feedback. We are in the midst now of cleaning this up, it might not make the next beta but will be updated soon.

 
Photo_37_small Steve Ehrenberg 2 posts

Thanks for all the tips here. I was going through the book fairly well until I hit this snag…

On a side note, I will comment about the required programming knowledge mentioned here. I’m very new to Objective C programming. Never really touched C (but I know and understand the basics). I have 0 cocoa experience. I’ve been developing with Ruby for about 4 years now and have a pretty good understanding of OOP but am always open to learning more. The first 3 chapters have really felt like I’ve just been copy and pasting code. I don’t feel like I’m really ‘learning’ much about what I’m doing and more importantly, why. I’d love it if these chapters were fleshed out a little more to give a better understanding about what’s going on under the hood. For the time being, though, I’m keeping an open mind and figuring that as I progress through the book, some of the practices shown will start to just become habit for me. I’ll let you know how this goes when I’m done with the book..

 
Untitled_bigger_small Matthias Lübken 17 posts

Thanks too these comments really did help. – Additionally to the comments mentioned above I found particular irritating that the .XIB and .H were both named AddTeamViewController. Somewhat irritating.

I have one open problem with this chapter: I can’t see the “Navigation Item”. I’ve added the “Navigation Item”, set a title an successfully connected to the File’s owner. Doesn’t work. Any ideas?

 
Generic-user-small Ryan Chavez 2 posts

Yeah, I have to agree with Steve’s post above. I have about 10 years of OOP experience in Java. I also have a very strong CS background. But alas, I have zero experience with Objective-C and also very limited experience with UI/visual programming.

I am giving the book the benefit of the doubt and am trying to progress even though I don’t feel like I’m learning very much from chapters 2 & 3. I hit the same pitfalls in this thread, and Chapter 2 also was a bit challenging to get working.

But I would agree that I feel like I’m just typing and learning patterns instead of foundational concepts. Perhaps the intro needs to list some required reading before starting this book.

 
Generic-user-small Aneurin Bark... 4 posts

I believe the book is meant to be usable without required reading, and while I have at times felt like I’m just copying code I consider that a result of my own lack of understanding of Objective-C.

I too am giving it the benefit of the doubt, though I haven’t had time to progress past Chapter 3 since I last posted. Whenever I move on, though, I’m sure as I (slowly) progress I’ll begin to gain confidence, as I start to memorise the peculiar syntax.

 
Generic-user-small Marc Winoto 13 posts

While there are some areas that I think could use a few hints or tips, I think it’s a mistake to turn this into an Objective-C book (as well). The required reading is already available from Apple. And you don’t have to read that much to become productive in Obj-C.

Unless, they are giving me details on the behaviour of the framework, the more concise the better!

17 posts, 10 voices