Advertisement
Guest User

Ta super doc

a guest
Feb 27th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.53 KB | None | 0 0
  1.         // Pour check for update
  2.         WiFiConfiguration.checkForUpdate(currentVersion: currentVersion) { newVersion in
  3.             // Tu regardes si c'est différent
  4.             if newVersion > currentVersion {
  5.                 // Là c'est que t'as une MaJ
  6.                
  7.             } else {
  8.                 // Là c'est que t'en a pas
  9.                
  10.             }
  11.         }
  12.        
  13.         // Après pour update quand t'appuies sur le bouton
  14.         WiFiConfiguration.fetch(currentVersion: currentVersion) { newVersion, config in
  15.             // Tu vérifies que l'update s'est bien dl
  16.             if let config = config {
  17.                 // T'as la nouvelle version et la nouvelle config
  18.                 dataManager.datas.set(newVersion, forKey: "configVersion")
  19.                 dataManager.datas.set(config, forKey: "configData") // NB: Tu mets les keys que tu veux hein
  20.                 dataManager.datas.synchronize()
  21.             } else {
  22.                 // Soit ya pas d'update, soit ya eu une erreur dans le téléchargement
  23.                 // Conseil: bah tu fais rien ici, puisque ya rien à faire
  24.                 // A part peut être dire à l'utilisateur échec de la MaJ
  25.             }
  26.         }
  27.        
  28.         // Et pour lire la config dans le dataManager
  29.         var config = [String: WiFiConfiguration]() // Dans les déclarations en haut
  30.        
  31.         // Dans ta méthode d'init :
  32.         if let config = datas.value(forKey: "configData") as? [String: WiFiConfiguration] {
  33.             self.config = config
  34.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement