Explorar el Código

Add sychronizable

Evgenii Neumerzhitckii hace 9 años
padre
commit
c774062c12
Se han modificado 1 ficheros con 7 adiciones y 0 borrados
  1. 7 0
      Demo/ViewController.swift

+ 7 - 0
Demo/ViewController.swift

@@ -13,6 +13,8 @@ class ViewController: UIViewController {
   
   let keychain = KeychainSwift()
   
+  static let accessGroup = "synch keychain group"
+  
   override func viewDidLoad() {
     super.viewDidLoad()
     
@@ -27,6 +29,8 @@ class ViewController: UIViewController {
   @IBAction func onSaveTapped(sender: AnyObject) {
     if let text = textField.text {
       keychain.synchronizable = synchronizableSwitch.on
+//      keychain.accessGroup = synchronizableSwitch.on ? ViewController.accessGroup : nil
+      
       keychain.set(text, forKey: TegKeychainDemo_keyName)
       updateValueLabel()
     }
@@ -34,6 +38,8 @@ class ViewController: UIViewController {
   
   @IBAction func onDeleteTapped(sender: AnyObject) {
     keychain.synchronizable = synchronizableSwitch.on
+//    keychain.accessGroup = synchronizableSwitch.on ? ViewController.accessGroup : nil
+
     keychain.delete(TegKeychainDemo_keyName)
     updateValueLabel()
   }
@@ -44,6 +50,7 @@ class ViewController: UIViewController {
   
   private func updateValueLabel() {
     keychain.synchronizable = synchronizableSwitch.on
+//    keychain.accessGroup = synchronizableSwitch.on ? ViewController.accessGroup : nil
     
     if let value = keychain.get(TegKeychainDemo_keyName) {
       valueLabel.text = "In Keychain: \(value)"