Skip to content

Instantly share code, notes, and snippets.

@joshdance
Created March 13, 2018 06:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshdance/865b2cdf970d69153559eca39b52727f to your computer and use it in GitHub Desktop.
Save joshdance/865b2cdf970d69153559eca39b52727f to your computer and use it in GitHub Desktop.
func calculatePushupsToday() {
//get todays date
let calendar = NSCalendar.current
var todaysPushupNumber = 0
for workout in myArray {
//see if any of the entries = today
if calendar.isDateInToday(workout.dateOfSave) == true
{
//add them up.
todaysPushupNumber = todaysPushupNumber + workout.numberOfPushups
}
} //end for workout loop
let todaysPushupLabelText : String = String(todaysPushupNumber) + " pushups today"
pushupsTodayLabel.text = String(todaysPushupLabelText)
} //end calculatePushupsToday
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment