iOS Apprentice page 143 "updateLabels"

Just bought the book “iOS Apprentice” and I’m liking it so far. However, I stumbled upon a problem. When I have to code in “updateLabels()” I get an error message even though I’ve followed the instructions according to the book carefully. As I’m stuck at this point I’m wondering if anyone has encountered the same problem or if anyone knows how to solve this problem?

As I’m completely new to coding, I might have missed something a regular coder will notice right away.

My code is as follows:
"func startNewRound() {
targetValue = 1 + Int(arc4random_uniform(100))
currentValue = 50
slider.value = Float(currentValue)
And I get the following error message:
“Use of unresolved identifier ‘updateLabels’”

Can anybody help me move on in this so far great book?

I don’t have a copy of the book handy at the moment and so I don’t know if you’ve already added the code for the updateLabels method or not at this piont, but the error message simply indicates that Xcode (or rather the compiler) does not recognize a method named updateLabels.

So you might want to check the spelling for the method and the spelling for the line where you call the method to make sure that the spelling is correct.

On the other hand, if you have not added the method yet, then the error is normal since it will go away as soon as you’ve added the method :slight_smile:

If neither of these is the issue, then could you please ZIP up your project, upload it somewhere and then provide a link here? That way, I (or somebody else) can download the full project and run it to see what the issue might be …

1 Like

Thank you for your quick response.

By tweaking a bit here and there I finally resolved the problem!

Thank you.

Good to hear that you were able to resolve the issue :slight_smile:

In case it helps somebody else who might run into the same issue, can you please mention what fixed the issue for you?

1 Like

Sure :slight_smile:

I lack the coding terminology, but I basically did what follows:

Inserted this piece of code: “func updateLabels() {
targetLabel.text = String(targetValue)”

Above this piece of code: “func startNewRound() {
targetValue = 1 + Int(arc4random_uniform(100))
currentValue = 50
slider.value = Float(currentValue)

This made xCode understand what I wanted to do with the Bull’s Eye game (1st chapter of the book “iOS Apprentice”).

From what I understood from the book it explained it the other way around, but then again I might just be too new to coding to have understood it properly.

Ah, you might be working with an older edition of the book since I can’t find the section you mention on page 143 :slight_smile: And the newest edition (the 6th edition) does provide these instructions in the right order, if I’m not mistaken …

This topic was automatically closed after 166 days. New replies are no longer allowed.