<commit_before>//
//  PreferenceViewController.swift
//  ScreenRecord
//
//  Created by nakajijapan on 2016/02/21.
//  Copyright © 2016 nakajijapan. All rights reserved.
//

import Cocoa
import RxSwift
import RxCocoa
import RxBlocking

class PreferenceViewController: NSViewController, NSTextFieldDelegate {

    @IBOutlet weak var frameCountTextField: NSTextField!
    @IBOutlet weak var delayTimeTextField: NSTextField!
    let disposeBag = DisposeBag()

    override func viewDidLoad() {
        super.viewDidLoad()

        let secondPerFrame = UserDefaults.standard.float(forKey: "GifSecondPerFrame")
        frameCountTextField.doubleValue = Double(Int(secondPerFrame * 1000.0)) * 0.001
        
        let delayTime = UserDefaults.standard.double(forKey: "GifDelayTime")
        delayTimeTextField.doubleValue = Double(Int(delayTime * 1000.0)) * 0.001

        frameCountTextField.rx.text.subscribe(onNext: { (text) in
            guard let text = text else { return }
            UserDefaults.standard.set(text.floatValue, forKey: "GifSecondPerFrame")
        }, onError: nil, onCompleted: nil, onDisposed: nil).addDisposableTo(disposeBag)

        
        delayTimeTextField.rx.text.subscribe(onNext: { (text) in
            guard let text = text else { return }
            UserDefaults.standard.set(text.floatValue, forKey: "GifDelayTime")
        }, onError: nil, onCompleted: nil, onDisposed: nil).addDisposableTo(disposeBag)

    }

}<commit_msg>use disposed<commit_after>//
//  PreferenceViewController.swift
//  ScreenRecord
//
//  Created by nakajijapan on 2016/02/21.
//  Copyright © 2016 nakajijapan. All rights reserved.
//

import Cocoa
import RxSwift
import RxCocoa
import RxBlocking

class PreferenceViewController: NSViewController, NSTextFieldDelegate {

    @IBOutlet weak var frameCountTextField: NSTextField!
    @IBOutlet weak var delayTimeTextField: NSTextField!
    let disposeBag = DisposeBag()

    override func viewDidLoad() {
        super.viewDidLoad()

        let secondPerFrame = UserDefaults.standard.float(forKey: "GifSecondPerFrame")
        frameCountTextField.doubleValue = Double(Int(secondPerFrame * 1000.0)) * 0.001
        
        let delayTime = UserDefaults.standard.double(forKey: "GifDelayTime")
        delayTimeTextField.doubleValue = Double(Int(delayTime * 1000.0)) * 0.001

        frameCountTextField.rx.text.subscribe(onNext: { (text) in
            guard let text = text else { return }
            UserDefaults.standard.set(text.floatValue, forKey: "GifSecondPerFrame")
        }, onError: nil, onCompleted: nil, onDisposed: nil).disposed(by: disposeBag)

        delayTimeTextField.rx.text.subscribe(onNext: { (text) in
            guard let text = text else { return }
            UserDefaults.standard.set(text.floatValue, forKey: "GifDelayTime")
        }, onError: nil, onCompleted: nil, onDisposed: nil).disposed(by: disposeBag)

    }
}
{'fraction_non_alphanumeric': 0.09838321293429653, 'fraction_numerical': 0.02063983488132095, 'mean_word_length': 3.314540059347181, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4108745', 'n_tokens_mistral': 940, 'n_tokens_neox': 847, 'n_words': 195}