<commit_before>//
//  Day36_SSKeychain.swift
//  swift101
//
//  Created by <NAME> on 12/13/2558 BE.
//  Copyright © 2558 iGROOMGRiM. All rights reserved.
//

import UIKit
import SSKeychain

class Day36ViewController: UIViewController {
    
    let ServiceName = "Swift101"
    
    override func viewDidLoad() {
        let sessionToken = "<KEY>"
        let sessionAccount = "<EMAIL>"
        
        self.setKeychain(sessionToken, sessionAccount: sessionAccount)
        
        print(SSKeychain.allAccounts())
    }
    
    override func viewDidAppear(animated: Bool) {
        self.viewDidDisappear(animated)
        
        let accounts = self.getAccountFromService()
        print(accounts)
        
        let accountDict = accounts[0] as! NSDictionary
        let account = accountDict["acct"] as! String
        
        let pwd = self.getPasswordFromAccount(account)
        
        print("password : \(pwd)")
        
    }
    
    private func setKeychain(sessionToken: String, sessionAccount: String) {
        SSKeychain.setPassword(sessionToken, forService: ServiceName, account: sessionAccount)
    }
    
    // Day 35 - Get accounts from your service
    private func getAccountFromService() -> NSArray {
        return SSKeychain.accountsForService(ServiceName)
    }
    
    // Day 34 - Get password from account
    private func getPasswordFromAccount(sessionAccount: String) -> String {
        return SSKeychain.passwordForService(ServiceName, account: sessionAccount)
    }
}
<commit_msg>Day 33 - SSKeychain : Delete password from account<commit_after>//
//  Day36_SSKeychain.swift
//  swift101
//
//  Created by <NAME> on 12/13/2558 BE.
//  Copyright © 2558 iGROOMGRiM. All rights reserved.
//

import UIKit
import SSKeychain

class Day36ViewController: UIViewController {
    
    let ServiceName = "Swift101"
    
    override func viewDidLoad() {
        let sessionToken = "<KEY>"
        let sessionAccount = "<EMAIL>"
        
        self.setKeychain(sessionToken, sessionAccount: sessionAccount)
        
        print(SSKeychain.allAccounts())
    }
    
    override func viewDidAppear(animated: Bool) {
        self.viewDidDisappear(animated)
        
        let accounts = self.getAccountFromService()
        print(accounts)
        
        let accountDict = accounts[0] as! NSDictionary
        let account = accountDict["acct"] as! String
        
        let pwd = self.getPasswordFromAccount(account)
        
        print("password : \(pwd)")
        
        if self.deletePasswordFromAccount(account) {
            print("Delete Password : Success")
        } else {
            print("Delete Password : Unsuccess")
        }
        
    }
    
    private func setKeychain(sessionToken: String, sessionAccount: String) {
        SSKeychain.setPassword(sessionToken, forService: ServiceName, account: sessionAccount)
    }
    
    // Day 35 - Get accounts from your service
    private func getAccountFromService() -> NSArray {
        return SSKeychain.accountsForService(ServiceName)
    }
    
    // Day 34 - Get password from account
    private func getPasswordFromAccount(sessionAccount: String) -> String {
        return SSKeychain.passwordForService(ServiceName, account: sessionAccount)
    }
    
    // Day 33 - Delete password from account
    private func deletePasswordFromAccount(sessionAccount: String) -> Bool {
        return SSKeychain.deletePasswordForService(ServiceName, account: sessionAccount)
    }
}

{'fraction_non_alphanumeric': 0.0860091743119266, 'fraction_numerical': 0.016628440366972478, 'mean_word_length': 2.4855144855144857, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1533336', 'n_tokens_mistral': 1006, 'n_tokens_neox': 954, 'n_words': 234}