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 trialmeitav asulin
1,123 PointsWhy the fundable.text was written in the override init and not before?
why?
2 Answers
Jeff McDivitt
23,970 PointsIt is difficult to answer questions when you do not post the code. If you could please post the code I would be happy to assist you!
meitav asulin
1,123 Pointsimport UIKit
class ViewController: UIViewController {
@IBOutlet weak var funFactLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
funFactLabel.text = "An interesting fact!"
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func showFact() {
funFactLabel.text = "Another interesting fact"
}
} Why did he write this in the override init and not outside the init- funFactLabel.text = "An interesting fact!"
Jeff McDivitt
23,970 PointsBecause then it will appear when the app is loaded; that is why it is inside viewDidLoad