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 trialWesley Jacobs
5,865 PointsUnable to access the facts.
When I'm trying to access the facts in the array it continues to tell me that "Instance member "Facts" cannot be used on type "FactProvider"
code for struct: struct FactProvider { let facts = [ "Ants stretch when they wake up in the morning.", "Etc..." ] }
code in the view controller import UIKit
class ViewController: UIViewController {
@IBOutlet weak var FunFactLabel: UILabel!
let factProvider = FactProvider()
override func viewDidLoad() {
super.viewDidLoad()
// THIS IS WHERE I GET THE ERROR FunFactLabel.text = FactProvider.facts[0]
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func showFact() {
}
}
1 Answer
Isaiah Marin
11,971 PointsHi,
So you are receiving an error when you include "FunFactLabel.text = FactProvider.facts[0]" inside the "viewDidLoad"? If so, I noticed you called "FactProvider.facts[0]", but maybe it should call "factProvider.facts[0]" instead.
Wesley Jacobs
5,865 PointsWesley Jacobs
5,865 PointsThat was it. Hahaha I was so frustrated!