<commit_before>//
//  EventFilterVC.swift
//  TapglueSample
//
//  Created by <NAME> on 16/12/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

//  Checked Default Array: will be initialized at NavigationController.


import UIKit

class EventFilterVC: UIViewController, UITableViewDelegate {
    
    let events: [String] = ["Likes", "Bookmarked", "Friend", "Follow", "Liked"]
    let eventType: [String] = ["like_event", "bookmark_event", "tg_friend", "tg_follow", "tg_like"]
    
    var checked: [Bool] = []
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }

    override func viewWillAppear(animated: Bool) {
        readChecked()
    }
    
    func readChecked()  {
        // get default checked arr
        let defaults = NSUserDefaults.standardUserDefaults()
        checked = defaults.objectForKey("checked") as! [Bool]
    }
    
    // Back button pressed
    override func willMoveToParentViewController(parent: UIViewController?) {
        if parent == nil {
            
            // Save checked to defaults
            let defaults = NSUserDefaults.standardUserDefaults()
            defaults.setObject(checked, forKey: "checked")
            defaults.synchronize()
        }
    }
}

extension EventFilterVC: UITableViewDataSource {
    // MARK: -TableView
    func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 1
    }
    
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return self.events.count
    }
    
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! EventFilterTableViewCell
        
        cell.eventNameLabel.text = events[indexPath.row]
        
        if checked[indexPath.row] == false {
            cell.accessoryType = .None
        } else if checked[indexPath.row] == true {
            cell.accessoryType = .Checkmark
        }
        
        return cell
    }
    
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        if let cell = tableView.cellForRowAtIndexPath(indexPath) {
            if cell.accessoryType == .Checkmark{
                cell.accessoryType = .None
                checked[indexPath.row] = false
            } else{
                cell.accessoryType = .Checkmark
                checked[indexPath.row] = true
            }
        }
    }
}<commit_msg>Refactored naming<commit_after>//
//  EventFilterVC.swift
//  TapglueSample
//
//  Created by <NAME> on 16/12/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

//  Checked Default Array: will be initialized at NavigationController.


import UIKit

class EventFilterVC: UIViewController, UITableViewDelegate {
    
    let events: [String] = ["Likes", "Bookmarked", "Friend", "Follow", "Liked"]
    let eventType: [String] = ["like_event", "bookmark_event", "tg_friend", "tg_follow", "tg_like"]
    
    var filterCheckmarks: [Bool] = []
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }

    override func viewWillAppear(animated: Bool) {
        readFilterCheckmarks()
    }
    
    func readFilterCheckmarks()  {
        // get default checked arr
        let defaults = NSUserDefaults.standardUserDefaults()
        filterCheckmarks = defaults.objectForKey("filterCheckmarks") as! [Bool]
    }
    
    // Back button pressed
    override func willMoveToParentViewController(parent: UIViewController?) {
        if parent == nil {
            
            // Save checked to defaults
            let defaults = NSUserDefaults.standardUserDefaults()
            defaults.setObject(filterCheckmarks, forKey: "filterCheckmarks")
            defaults.synchronize()
        }
    }
}

extension EventFilterVC: UITableViewDataSource {
    // MARK: -TableView
    func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 1
    }
    
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return self.events.count
    }
    
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! EventFilterTableViewCell
        
        cell.eventNameLabel.text = events[indexPath.row]
        
        if filterCheckmarks[indexPath.row] == false {
            cell.accessoryType = .None
        } else if filterCheckmarks[indexPath.row] == true {
            cell.accessoryType = .Checkmark
        }
        
        return cell
    }
    
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        if let cell = tableView.cellForRowAtIndexPath(indexPath) {
            if cell.accessoryType == .Checkmark{
                cell.accessoryType = .None
                filterCheckmarks[indexPath.row] = false
            } else{
                cell.accessoryType = .Checkmark
                filterCheckmarks[indexPath.row] = true
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.09553277895958229, 'fraction_numerical': 0.0042544962289692515, 'mean_word_length': 2.349740932642487, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '7227580', 'n_tokens_mistral': 1507, 'n_tokens_neox': 1410, 'n_words': 325}