Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Pour check for update
- WiFiConfiguration.checkForUpdate(currentVersion: currentVersion) { newVersion in
- // Tu regardes si c'est différent
- if newVersion > currentVersion {
- // Là c'est que t'as une MaJ
- } else {
- // Là c'est que t'en a pas
- }
- }
- // Après pour update quand t'appuies sur le bouton
- WiFiConfiguration.fetch(currentVersion: currentVersion) { newVersion, config in
- // Tu vérifies que l'update s'est bien dl
- if let config = config {
- // T'as la nouvelle version et la nouvelle config
- dataManager.datas.set(newVersion, forKey: "configVersion")
- dataManager.datas.set(config, forKey: "configData") // NB: Tu mets les keys que tu veux hein
- dataManager.datas.synchronize()
- } else {
- // Soit ya pas d'update, soit ya eu une erreur dans le téléchargement
- // Conseil: bah tu fais rien ici, puisque ya rien à faire
- // A part peut être dire à l'utilisateur échec de la MaJ
- }
- }
- // Et pour lire la config dans le dataManager
- var config = [String: WiFiConfiguration]() // Dans les déclarations en haut
- // Dans ta méthode d'init :
- if let config = datas.value(forKey: "configData") as? [String: WiFiConfiguration] {
- self.config = config
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement