Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

alexander88
alexander88
10,824 Points

Xcode has been updated and the code in the videos hasn't been working correctly. issue: "unresolved identifier 'facts'"

I've been running into problems with all the code in the creating a basic iphone app series of videos. Most of Pasan's code has some tiny error here or there after the latest update. My latest issue I've encountered is that the following code comes up with the error "use of unresolved identifier 'facts'" twice:

func randomFact() -> String {

    let randomNumber = GKRandomSource.sharedRandom().nextInt(upperBound: facts.count)

    return facts[randomNumber]
}

To remedy this I tried changing it to:

 func randomFact() -> String {

    let randomNumber = GKRandomSource.sharedRandom().nextInt(upperBound: FactProvider.facts.count)

    return FactProvider.facts[randomNumber]
}

FactProvider.facts.count came up with the error: "Instance member 'facts' cannot be used on type FactProvider"

While FactsProvider.facts[randomNumber] worked just fine. If someone could explain how to fix this as well as why the code worked the second time but not the first it would be a huge help. Thanks in advance.

1 Answer

Clark Reilly
Clark Reilly
6,204 Points

Could you post the code containing the declaration of facts or a link to the project files? Otherwise I can't really help you.