<commit_before>//
//  ViewController.swift
//  Demo
//
//  Created by <NAME> on 2016-12-02.
//  Copyright © 2016 JagCesar. All rights reserved.
//

import UIKit
import CloudKitCurrentUser

class ViewController: UIViewController {

    @IBOutlet var textView: UITextView!
    override func viewDidLoad() {
        super.viewDidLoad()

        NotificationCenter.default.addObserver(self,
                                               selector: #selector(ViewController.getUserStatus),
                                               name: CurrentUser.statusChangedNotification,
                                               object: nil)
    }

    deinit {
        NotificationCenter.default.removeObserver(self)
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)

        getUserStatus()
    }

    @IBAction func forceReloadUserStatus() {
        logStatusChange(string: "Force reload of user")
        CurrentUser.sharedInstance.currentStatus(forcedReload: true) { status in
            self.logStatusChange(status: status)
        }
    }

    @IBAction func logUserIdentifier() {
        logStatusChange(string: "Log user identifier")
            CurrentUser.sharedInstance.userIdentifier { userIdentifier, error in
                if let userIdentifier = userIdentifier {
                    self.logStatusChange(string: "User identifier: \(userIdentifier.userIdentifierString)")
                } else {
                    self.logStatusChange(string: "Unable to get user identifier")
                }
        }
    }

    @objc private func getUserStatus() {
        CurrentUser.sharedInstance.currentStatus { status in
            self.logStatusChange(status: status)
        }<commit_msg>Updates Demo so it works with the new code<commit_after>//
//  ViewController.swift
//  Demo
//
//  Created by <NAME> on 2016-12-02.
//  Copyright © 2016 JagCesar. All rights reserved.
//

import UIKit
import CloudKitCurrentUser

class ViewController: UIViewController {

    @IBOutlet var textView: UITextView!
    override func viewDidLoad() {
        super.viewDidLoad()

        NotificationCenter.default.addObserver(self,
                                               selector: #selector(ViewController.getUserStatus),
                                               name: CurrentUser.statusChangedNotification,
                                               object: nil)
    }

    deinit {
        NotificationCenter.default.removeObserver(self)
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)

        getUserStatus()
    }

    @IBAction func forceReloadUserStatus() {
        logStatusChange(string: "Force reload of user")
        CurrentUser.sharedInstance.currentStatus(forcedReload: true) { status, error in
            self.logStatusChange(status: status)
        }
    }

    @IBAction func logUserIdentifier() {
        logStatusChange(string: "Log user identifier")
            CurrentUser.sharedInstance.userIdentifier { userIdentifier, error in
                if let userIdentifier = userIdentifier {
                    self.logStatusChange(string: "User identifier: \(userIdentifier)")
                } else {
                    self.logStatusChange(string: "Unable to get user identifier")
                }
        }
    }

    @objc private func getUserStatus() {
        CurrentUser.sharedInstance.currentStatus { status, error in
            self.logStatusChange(status: status)
        }
{'fraction_non_alphanumeric': 0.07939669891861127, 'fraction_numerical': 0.006829823562891292, 'mean_word_length': 1.9737732656514382, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1326944', 'n_tokens_mistral': 895, 'n_tokens_neox': 827, 'n_words': 200}