<commit_before>//
//  ViewController.swift
//  Checklists10
//
//  Created by <NAME> on 17.10.16.
//  Copyright © 2016 Closure One. All rights reserved.
//

import UIKit

class Checklist10ViewController: UITableViewController {
  
  var items: [Checklist10Item]
  
  
  required init?(coder aDecoder: NSCoder) {
    items = [Checklist10Item]()
    
    let row0item = Checklist10Item()
    row0item.text = "Walk the dog"
    row0item.checked = false
    items.append(row0item)
    let row1item = Checklist10Item()
    row1item.text = "Brush my teeth"
    row1item.checked = true
    items.append(row1item)
    let row2item = Checklist10Item()
    row2item.text = "Learn iOS development"
    row2item.checked = true
    items.append(row2item)
    let row3item = Checklist10Item()
    row3item.text = "Soccer practice"
    row3item.checked = false
    items.append(row3item)
    let row4item = Checklist10Item()
    row4item.text = "Eat ice cream"
    row4item.checked = true
    items.append(row4item)
    
    super.init(coder: aDecoder)
  }

  override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
  }

  override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
  }
  
  // MARK: TV Data Source related
  override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 5
  }
  
  override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    
    print("cellForRowAt indexPath: \(indexPath )")
    
    let cell = tableView.dequeueReusableCell(withIdentifier: "ChecklistItem", for: indexPath)
    
    if let label = cell.viewWithTag(1000) as! UILabel? {
      if indexPath.row == 0 {
        label.text = items[0].text
      } else if indexPath.row == 1 {
        label.text = items[1].text
      } else if indexPath.row == 2 {
        label.text = items[2].text
      } else if indexPath.row == 3 {
        label.text = items[3].text
      } else if indexPath.row == 4 {
        label.text = items[4].text
      }
    }
    
     configureCheckmark(for: cell, at: indexPath)
    
    return cell
  }
  
  // MARK: TV delegate related
  
  override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    
    print("didSelectRowAt indexPath: \(indexPath )")
    
    if let cell = tableView.cellForRow(at: indexPath) {
      if indexPath.row == 0 {
        items[0].checked = !items[0].checked
      } else if indexPath.row == 1 {
        items[1].checked = !items[1].checked
      } else if indexPath.row == 2 {
        items[2].checked = !items[2].checked
      } else if indexPath.row == 3 {
        items[3].checked = !items[3].checked
      } else if indexPath.row == 4 {
        items[4].checked = !items[4].checked
      }
     configureCheckmark(for: cell, at: indexPath)
      
    }
    
    tableView.deselectRow(at: indexPath, animated: true)
  }
  
  // MARK Individual methods
  
  func configureCheckmark(for cell: UITableViewCell, at indexPath: IndexPath) {
    
    print("configureCheckmark cell: \(cell) indexPath: \(indexPath )")

    var isChecked = false
   
    if indexPath.row == 0 {
      isChecked = items[0].checked
    } else if indexPath.row == 1 {
      isChecked = items[1].checked
    } else if indexPath.row == 2 {
      isChecked = items[2].checked
    } else if indexPath.row == 3 {
      isChecked = items[3].checked
    } else if indexPath.row == 4 {
      isChecked = items[4].checked
    }
    if isChecked {
      cell.accessoryType = .checkmark
    } else {
      cell.accessoryType = .none
    }
  }
  <commit_msg>Putting the vars into an array.<commit_after>//
//  ViewController.swift
//  Checklists10
//
//  Created by <NAME> on 17.10.16.
//  Copyright © 2016 Closure One. All rights reserved.
//

import UIKit

class Checklist10ViewController: UITableViewController {
  
  var checklist10Items: [Checklist10Item]
  
  
  required init?(coder aDecoder: NSCoder) {
    checklist10Items = [Checklist10Item]()
    
    let row0item = Checklist10Item()
    row0item.text = "Walk the dog"
    row0item.checked = false
    checklist10Items.append(row0item)
    let row1item = Checklist10Item()
    row1item.text = "Brush my teeth"
    row1item.checked = true
    checklist10Items.append(row1item)
    let row2item = Checklist10Item()
    row2item.text = "Learn iOS development"
    row2item.checked = true
    checklist10Items.append(row2item)
    let row3item = Checklist10Item()
    row3item.text = "Soccer practice"
    row3item.checked = false
    checklist10Items.append(row3item)
    let row4item = Checklist10Item()
    row4item.text = "Eat ice cream"
    row4item.checked = true
    checklist10Items.append(row4item)
    
    super.init(coder: aDecoder)
  }

  override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
  }

  override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
  }
  
  // MARK: TV Data Source related
  override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 5
  }
  
  override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    
    print("cellForRowAt indexPath: \(indexPath )")
    
    let cell = tableView.dequeueReusableCell(withIdentifier: "ChecklistItem", for: indexPath)
    
    if let label = cell.viewWithTag(1000) as! UILabel? {
      if indexPath.row == 0 {
        label.text = checklist10Items[0].text
      } else if indexPath.row == 1 {
        label.text = checklist10Items[1].text
      } else if indexPath.row == 2 {
        label.text = checklist10Items[2].text
      } else if indexPath.row == 3 {
        label.text = checklist10Items[3].text
      } else if indexPath.row == 4 {
        label.text = checklist10Items[4].text
      }
    }
    
     configureCheckmark(for: cell, at: indexPath)
    
    return cell
  }
  
  // MARK: TV delegate related
  
  override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    
    print("didSelectRowAt indexPath: \(indexPath )")
    
    if let cell = tableView.cellForRow(at: indexPath) {
      if indexPath.row == 0 {
        checklist10Items[0].checked = !checklist10Items[0].checked
      } else if indexPath.row == 1 {
        checklist10Items[1].checked = !checklist10Items[1].checked
      } else if indexPath.row == 2 {
        checklist10Items[2].checked = !checklist10Items[2].checked
      } else if indexPath.row == 3 {
        checklist10Items[3].checked = !checklist10Items[3].checked
      } else if indexPath.row == 4 {
        checklist10Items[4].checked = !checklist10Items[4].checked
      }
     configureCheckmark(for: cell, at: indexPath)
      
    }
    
    tableView.deselectRow(at: indexPath, animated: true)
  }
  
  // MARK Individual methods
  
  func configureCheckmark(for cell: UITableViewCell, at indexPath: IndexPath) {
    
    print("configureCheckmark cell: \(cell) indexPath: \(indexPath )")

    var isChecked = false
   
    if indexPath.row == 0 {
      isChecked = checklist10Items[0].checked
    } else if indexPath.row == 1 {
      isChecked = checklist10Items[1].checked
    } else if indexPath.row == 2 {
      isChecked = checklist10Items[2].checked
    } else if indexPath.row == 3 {
      isChecked = checklist10Items[3].checked
    } else if indexPath.row == 4 {
      isChecked = checklist10Items[4].checked
    }
    if isChecked {
      cell.accessoryType = .checkmark
    } else {
      cell.accessoryType = .none
    }
  }
  
{'fraction_non_alphanumeric': 0.10453902533110454, 'fraction_numerical': 0.029574386010029576, 'mean_word_length': 2.684509711037423, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '379459', 'n_tokens_mistral': 2603, 'n_tokens_neox': 2434, 'n_words': 595}