Skip to content

Instantly share code, notes, and snippets.

@ashour
Last active June 12, 2019 09:09
Show Gist options
  • Save ashour/c7ed0c38ef121d09778b6163d82f8e63 to your computer and use it in GitHub Desktop.
Save ashour/c7ed0c38ef121d09778b6163d82f8e63 to your computer and use it in GitHub Desktop.
import UIKit
class TrackDetailsViewController: UIViewController {
// ...
@IBOutlet weak var copyrightLabel: UILabel!
var track: Track?
override func viewDidLoad() {
super.viewDidLoad()
if let track = track {
// ...
copyrightLabel.text = getCopyrightText(artistName: track.artistName)
}
}
func setup(with track: Track) {
self.track = track
}
fileprivate func getCopyrightText(artistName: String) -> String {
let format = NSLocalizedString("copyright", comment: "")
let currentYear = "\(Calendar.current.component(.year, from: Date()))"
return String.localizedStringWithFormat(format, currentYear, artistName)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment