Skip to content

Instantly share code, notes, and snippets.

@Shinolr
Last active April 30, 2019 11:57
Show Gist options
  • Select an option

  • Save Shinolr/76f9814954e9026ed247e7fef56adbc2 to your computer and use it in GitHub Desktop.

Select an option

Save Shinolr/76f9814954e9026ed247e7fef56adbc2 to your computer and use it in GitHub Desktop.

Revisions

  1. Shinolr revised this gist Apr 30, 2019. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions AppGuide.swift
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,3 @@
    import Foundation

    protocol AppGuide {
    func shouldLoadAppGuide() -> Bool
    }
  2. Shinolr created this gist Apr 30, 2019.
    23 changes: 23 additions & 0 deletions AppGuide.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    import Foundation

    protocol AppGuide {
    func shouldLoadAppGuide() -> Bool
    }

    extension AppGuide {
    func shouldLoadAppGuide() -> Bool {
    guard let versionString = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String else {
    return false
    }
    guard let currentVersion = Int(versionString) else {
    return false
    }
    let lastVersion = UserDefaults.standard.integer(forKey: "CFBundleVersion")

    guard currentVersion > lastVersion else {
    return false
    }
    UserDefaults.standard.set(currentVersion, forKey: "CFBundleVersion")
    return true
    }
    }