Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
  2.  
  3. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  4. return cities.count
  5. }
  6.  
  7. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  8. let cell = UITableViewCell(style: UITableViewCell.CellStyle.default, reuseIdentifier: "Cell")
  9.  
  10. cell.textLabel?.text = "In (cities[indexPath.row]) it's (cities.description + Calendar.Component.hour)"
  11.  
  12.  
  13. return cell
  14. }
  15.  
  16. let cities:[String:Int] = ["Rome": +1 ,"London": 0, "Los Angeles" : -8, "Seul" : +9,"Honolulu": -10, "Pechino" : +8, "Il Cairo": +2, "Tokyo" : +9]
  17.  
  18. override func viewDidLoad() {
  19.  
  20. super.viewDidLoad()
  21. //Takes the date from the device
  22.  
  23. let date = Date()
  24. let formatter = DateFormatter()
  25. formatter.dateFormat = "dd.MM.yyyy"
  26. let result = formatter.date(from: "date")
  27.  
  28. //Takes the time from the device
  29. var calendar = Calendar.current
  30. var hour = calendar.component(.hour, from: date)
  31. var minutes = calendar.component(.minute, from: date)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement