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

Updating Information Everyday

I'm making an app that displays three different numbers everyday. The number depends on the current date and two other integers given by the user. Each of the three numbers has their own label and everyday I want the label to change to display that days number. I've written each equation to calculate the number in its own function. (one function is used as an example below this). I've tried editing the AppDelegate in the "ApplicationDidEnterForeground" func to update the labels (function also shown below) but it did not work. Any help would be appreciated as this would be my first app. (My variables are named the same as parameters in the functions)

Equation to Calculate One of The Numbers

 // Intellectual Equation
func intellect(pi: Double, age: Double, daysSinceBday: Double) -> Int {
    let intellectEq = 50.00 * sin((2.00*pi/28)*((age)*365.25) + daysSinceBday) + 50.00
    print(intellectEq)
    let intellectualAsString = intellect(pi: pi, age: age, daysSinceBday: daysSinceBday)
    self.IntellectualLabel.text = "\(intellectualAsString)"
    return intellectualAsString
}

Function to Update Labels

  func getCurrentEquationData(pi: Double, age: Double, daysSinceBday: Double) {
        intellect(pi: pi, age: age, daysSinceBday: daysSinceBday)
}

In the AppDelegate, I called:

getCurrentEquationData(pi: pi, age: age, daysSinceBday: daysSinceBday)