Your First iOS App: Coding in Swift

Jul 28 2026 · Swift 6.3, iOS 26, Xcode 26

Lesson 07: Variables & Constants

Variables & Constants

Episode complete

Play next episode

Next

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

At this point, you’ve simplified your algorithm to calculate the difference down a few lines of code.

var difference: Int = abs(target - sliderValue)
let awardedPoints: Int = 100 - difference
let awardedPoints: Int = 100 - difference
let roundedValue: Int = Int(sliderValue.rounded())
let guess = game.target + 5
let score = game.points(sliderValue: guess)
See forum comments
Cinema mode Download course materials from Github
Previous: Challenge: Calculate the Difference Next: Type Inference