Search
Rich's Mad Rants
Powered by Squarespace

Creating iOS 5 Apps Discussion > Chapter 3: Section - Connecting the Model

Rich,

First, I have been enjoying the read through your updated "Creating iOS 5 Apps". I have been working diligently through the examples and double checking my typing against the downloaded source code. At the end of the "Connecting the Model" section of chapter 3 you ask us to run the program and check for the two NSLog calls in the "viewDidAppear" method. When I look at your example, your first NSLog call results in a pointer address being returned. My code, when run, returns null. I have searched high and low through my code and I can't see why my code isn't reporting the pointer address like yours does. Any ideas?

Second, I felt like I should contribute to the cause. I think I found two typos as well:

1. In the same section as above there is a line that reads "That's it. We can verify that our data is making it all the way to our detail view by opening DetailViewController.m and navigating to the viewDidApepar: method."
- Obviously it was intended as "viewDidAppear" as is correctly noted in the example below it.

2. In Chapter 3, Section "Building the Model", Sub-Section "The WeightHistory Class" shortly after figure 3.21 there is a line that reads "Next, look at our implementation of addWeight: and removeWeightAtIndex:." In that section of code, directly below the line "// This will be auto KVO'ed." it appears that there is an extra semi-colon in that method implementation. I don't know that much about Objective-C, but it doesn't seem to be consistent with other code examples in the book.

Let me know your thoughts on the reason for that NSLog call not displaying the pointer address as your example does.

Thank you,
AJ

January 24, 2012 | Unregistered CommenterAJ

AJ, I'm glad you're enjoying the book.

There are a number of things that must happen for this to work. A problem anywhere along the line could cause it to fail (which is why I put in the sanity check).

1) We need to create our model in the tab bar controller's viewDidLoad method.
2) It needs to be passed to the history view controller at the end of the same viewDidLoad method
3) In the history view controller's prepareForSegue:sender: method, it needs to be passed to the detail view controller.

Most likely there's a problem in either the code that forwards the model to the view controllers (for example, a misspelling in the @selectors), or in the prepareForSegue:sender: (for example, if the segue identifier in the storyboard doesn't match the string in the code).

I'd recommend placing a breakpoint in both files where the weight history is assigned, and make sure they're getting called, and that the weight history value is not nil. This should help you narrow down where the problem is.

Finally, thank you for the typos. I'll add them to the errata.

January 25, 2012 | Registered CommenterRichard Warren

Thanks Rich. I figured it out following your steps. It turns out I missed adding the prepareForSegue method entirely! I have the kindle edition, so sometimes the pages format themselves oddly with breaks in the middle of code sections. I like the way you applied color to sections of code being added to outline which parts are new and which are original. Very helpful. I recently bought a kindle fire in hopes that the kindle edition of the book would magically apply the same color-coding techniques that Xcode employs. Alas it seems to be in black-and-white like many other coding books I've read. I think it would be helpful to show the various programming elements in Xcode-like color-coding for us Objective-C novices. To me, having color-coding is one of the elements that make working in an IDE so much better than a standard text editor (amongst many other things of course).

Thanks again for your help,
AJ

January 25, 2012 | Unregistered CommenterAJ

Thanks Rich. I figured it out following your steps. It turns out I missed adding the prepareForSegue method entirely! I have the kindle edition, so sometimes the pages format themselves oddly with breaks in the middle of code sections. I like the way you applied color to sections of code being added to outline which parts are new and which are original. Very helpful. I recently bought a kindle fire in hopes that the kindle edition of the book would magically apply the same color-coding techniques that Xcode employs. Alas it seems to be in black-and-white like many other coding books I've read. I think it would be helpful to show the various programming elements in Xcode-like color-coding for us Objective-C novices. To me, having color-coding is one of the elements that make working in an IDE so much better than a standard text editor (amongst many other things of course).

Thanks again for your help,
AJ

January 25, 2012 | Unregistered CommenterAJ

Sorry for the double post. Chrome's fault, not mine!

-AJ

January 25, 2012 | Unregistered CommenterAJ

Yep, according to the formatting they gave me, I only had two colors. Black and a highlight color. I'm not sure why we didn't use the syntax-highlighted code, since all the illustrations were full-color, but it's probably a price thing. On the other hand, that meant I could use the accent color to highlight the new code or the changes--so it's not all bad.

January 26, 2012 | Registered CommenterRichard Warren

Thank you for this thread. I was going crazy as well. It turns out I coded the TabBarController code in the viewDidUnload method instead. DOH! Awesome book so far, this is exactly the techniques I'm looking for. Outstanding! Now on to chapter 4 :-)

February 5, 2012 | Unregistered CommenterLoye