iCloudStatusCell.swift 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //
  2. // iCloudStatusCell.swift
  3. // Bark
  4. //
  5. // Created by huangfeng on 2020/5/29.
  6. // Copyright © 2020 Fin. All rights reserved.
  7. //
  8. import CloudKit
  9. import UIKit
  10. class iCloudStatusCell: UITableViewCell {
  11. override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
  12. super.init(style: .value1, reuseIdentifier: reuseIdentifier)
  13. self.selectionStyle = .none
  14. self.backgroundColor = BKColor.background.secondary
  15. self.textLabel?.text = NSLocalizedString("iCloudSatatus")
  16. self.detailTextLabel?.text = ""
  17. self.detailTextLabel?.textColor = BKColor.grey.darken2
  18. CKContainer.default().accountStatus { status, _ in
  19. dispatch_sync_safely_main_queue {
  20. switch status {
  21. case .available:
  22. self.detailTextLabel?.text = NSLocalizedString("available")
  23. case .noAccount, .restricted, .temporarilyUnavailable:
  24. self.detailTextLabel?.text = NSLocalizedString("restricted")
  25. case .couldNotDetermine:
  26. self.detailTextLabel?.text = NSLocalizedString("unknown")
  27. @unknown default:
  28. break
  29. }
  30. }
  31. }
  32. }
  33. @available(*, unavailable)
  34. required init?(coder aDecoder: NSCoder) {
  35. fatalError("init(coder:) has not been implemented")
  36. }
  37. }