Beersong won't work, and confused about Turkey


EDIT: Fixed, removed the “singSongFor(OneFewer);” line and ran the program, then pasted it back in again and ran the program again and it worked, I have no idea why that fixed it as the code is exactly the same as it was… If someone can explain why that fixed it I would be grateful!

Hi, I’m using Xcode 6 beta (not sure if that’s a problem) and I’ve just started Objective-C.

I cannot find a single mistake in my program, I even tried directly copying and pasting from the book and it still does the same thing! It recycles four bottles but there is only one on the wall.



I will not move onto the next stage until I understand what’s wrong, I can only assume it’s because I’m using a beta of Xcode.

Also, something REALLY confused me with the Turkey Timer:

So the answer to the necessary minutes is 15 + 15 * the number called “pounds”, which is unknown.
The program is never told the value of “pounds”, although it is 9. Which is also the value of turkeyweight.
there is a line of code at the bottom which says "showCookTimeForTurkey(TurkeyWeight), does this somehow replace pounds with turkeyweight? I don’t remember reading how this works in the book, what page is it on?

Any help is much appreciated!


Hey jgegrm, I hope you’re not still stuck or worse have given up. I’m fairly new but i will try my best to explain the turkeyTimer function along with the pg and quote.

Remember that the main() file is executed first. So that gives us the value for turkeyWeight. The call of the function showCookTimeForTurkey(turkeyWeight) passes that value to showCookTimeForTurkey(int pounds). So in my understanding it passes the value of turkeyWeight and assigns it to a new int named pounds. It completes the calculations and prints then returns to the main() where the program ends.

Note: I have the physical copy of the book
Where this is explained in the book is on pg 34. If you read the paragraph just above the heading Scope it explains this. (not sure if i’m allowed to quote the book here, just inform me if i cannot and i will edit my post.) “For this example turkeyWeight with a value of 9 is passed as an argument to showCookTimeForTurkey(). That value is assigned to the parameter pounds, that is, it is copied into the functions frame.”