Guest User

Untitled

a guest
Nov 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. import UIKit
  2.  
  3. class likesObject: NSObject {
  4. // This is where I created the loop to solve for the total amount of likes
  5. func complimentsLikeTotal() -> Void {
  6. let monthlyLikes = [20, 15, 13, 32, 14, 38]
  7. var totalLikes = 0
  8. var runTotal = 0
  9.  
  10. while runTotal < monthlyLikes.count {
  11. totalLikes += monthlyLikes[runTotal]
  12. print(totalLikes)
  13. runTotal += 1
  14. }
  15.  
  16. }
  17. /*
  18. This is where I created the function to return how many all time likes there are in a phrase
  19. I want to use this function in the viewcontroller code on the label
  20. */
  21. func display() -> String {
  22. return "(complimentsLikeTotal) all time likes"
  23. }
  24.  
  25. }
  26.  
  27. import UIKit
  28.  
  29. class ViewController: UIViewController {
  30. @IBOutlet weak var inputLikesLabel: UILabel!
  31.  
  32. override func viewDidLoad() {
  33. super.viewDidLoad()
  34. // Here is where I don't know what to do with display and how to link it with the label
  35. self.inputLikesLabel.text = display
  36.  
  37. }
  38.  
  39. }
Add Comment
Please, Sign In to add comment