Creating iOS 5 Apps Discussion > My chapter 6 completed app didn't work at first
Sorry about the errata in Chapter 6. It's definitely one of the most complex parts of the book. I thought we'd double checked everything--but I guess we needed to triple check....
iCloud is not supported in the simulator; however, I just checked the source code from Chapter 6, and it runs fine in the simulator here. It just won't sync with iCloud (of course).

I have the same problem...
When entering a weight the graph shows zero, and the history view is empty.
By setting breakpoints I have traced the execution to the EnterWeightController -(IBAction)saveWeight:(id)sender, but the method -(void)addWeight:(WeightEntry *)weight in the WeightHistory is never reach, which I believe is the method responsible for adding entries to the model.
I have no idea why this is not happening, from what I understand this method is called from the saveWeight method, by [self.weightHistory addWeight:entry];. I have no more ideas how to trace this problem further. My Issue looks very similar to Scots.
What can cause this issue?
Regards
Thor

Thor,
Let me see if I understand.
You placed breakpoints in the first line of both EnterWeightViewController's setWeight: method and WeightHistory's addWeight: method.
When you try to add a weight, your application stops in the setWeight: method. You step through the method, and you can see that it calls [self.weightHistory addWeight:entry], however the second breakpoint is never triggered.
Is that correct?
If that's the problem, then it sounds like you're not creating the weight history object. Next time you run it, stop in setWeight: and check the value of self.weightHistory. If it is nil, you're weight history is not being created properly. Double check the code for TabBarController's viewDidLoad: method. That's probably where the problem is.
Remember, in Objective-C, we can send methods to nil values--however they don't do anything. They just return 0. So, if you ever see code that's calling a method, but that method doesn't seem to actually get called, check and make sure you're not sending the method to a nil valued object.
If this doesn't help, try downloading the source code for the chapter. Can you build and run it? Does it add weights correctly? If my source code is working properly, you can compare your version to my version. That might help you find the problem.
I hope this helps.
-Rich-

WeightHistory.h & .m are missing from the Chapter 6 code.

OldWeightHistory exists.

Looks like something was wrong with the Chapter 6 source code. I rebounded it and uploaded it again. Let me know if you're still having problems with it.
-Rich-

I had exact same problem as "Scott" mentioned and tried to be debug 2 days on why "addWeight" would never get called after adding weight from EnterWeightController
even added respondToSelector to find out that WeightHistory was nil. I should have dig in more as while debugging i found that TabBarController.m viewDidLoad is the one setting it to nil.
I made a typo initially that entire code runs under "block". I mistakenly took out the
while ([stack count] > 0) {
}
loop outside of the block! I did file compare from chapter 6 to mine.
Now everything is working fine except my shake event never fire or show me any alert in HistoryViewController.

On the shake events. Make sure you override HistoryViewController
's canBecomeFirstResponder
method, and have it return YES
. Then call [self becomeFirstResponder];
in viewDidAppear:
. It won't receive motion events if it's not the first responder.
If that doesn't fix it, double check the motionEnded:withEvent:
method (and in particular, the method name's spelling). Place a breakpoint inside the method and make sure it's getting called. If it isn't, place a breakpoint inside canBecomeFirstResponder
and make sure it's getting called.
I hope that helps,
-Rich-

Thanks but it was typo on pg 362 to which you already added in errata. App is working fine
Thanks
G

I worked painstakingly through this behemoth of a chapter, resolved a few issues that were preventing a successful build, and ran my app in the simulator...and it didn't work. Added weights were not reflected in the graph or history views. So I tried setting some breakpoints to see what was going wrong, but didn't come up with anything. I tried running it on my iPhone 4S device, and I got a crasher on launch. Something about getting a lock from a different thread to UIKit. Xcode was even crashing whenever I went in to the storyboard and right-clicked on objects to review connections (crash log mentioned something about source cache).
So I started to cross-compare my code, file by file, with the download source code, and discovered that the download source code is not identical to what is presented in the book, at least the chapter 6 version. I first discovered this in EnterWeightViewController when I did not see the downSwipeRecognizer property. So I gave up on that option...if one thing is different there could be others.
So I reverted to my last known-working version from git (see below), which was chapter 5 completed, and it worked fine. I was about to start all over again with chapter 6, but first I wanted to post a link to my defunct project for you/someone to take a look at. So I checked out the most recent version from git (the one that isn't working). And, thankfully, decided to run it again, in the simulator and on my iOS device, and guess what? It still didn't work in the simulator, but it works fine on my devices, iPhone and iPad, iCloud doing its thing as advertised. Happy about that, but wonder WTF happened?
I am presuming that this does not work in the simulator because of iCloud (I used my own identifier)?
Re: git, I found a very helpful post from rsanchezsaez on stackoverflow.com on reverting to previous git commits, something you apparently cannot do from within Xcode...
http://stackoverflow.com/questions/5302367/xcode-4-git-integration/5364900#5364900