<commit_before>//
//  NoteTableViewController.swift
//  Noted
//
//  Created by <NAME> on 1/23/16.
//  Copyright © 2016 Usonia LLC. All rights reserved.
//

import UIKit
import CoreData

class NoteTableViewController: UITableViewController {
    
    // TODO: Might be temporary. Look into reloading tableview without needing this
    @IBOutlet var noteTable: UITableView!
    
    var notes: [Note] = []
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Get notes in storage
        notes = fetchNotes()
        
    }
    
    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 1
    }

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return notes.count
    }

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        // Get the cell object
        let cell = tableView.dequeueReusableCellWithIdentifier("noteCell", forIndexPath: indexPath)
        // Set the cells text label equal to our note text
        cell.textLabel?.text = notes[indexPath.row].note
        return cell
    }
    
    override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        return true
    }
    
    override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
        if (editingStyle == UITableViewCellEditingStyle.Delete) {
            // Remove deleted note
            notes[indexPath.row].delete()
            notes.removeAtIndex(indexPath.row)
            // Reload the table
            noteTable.reloadData()
        }
    }
    
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Pass the note object of the selected row to the edit view controller
        if (segue.identifier == "edit") {
            let destination = segue.destinationViewController as? EditViewController;
            let cell = sender as! UITableViewCell
            let selectedRow = tableView.indexPathForCell(cell)!.row
            destination!.selectedValue = notes[selectedRow]
        }
    }
    
}








<commit_msg>Animate note deletion<commit_after>//
//  NoteTableViewController.swift
//  Noted
//
//  Created by <NAME> on 1/23/16.
//  Copyright © 2016 Usonia LLC. All rights reserved.
//

import UIKit
import CoreData

class NoteTableViewController: UITableViewController {
    
    // TODO: Might be temporary. Look into reloading tableview without needing this
    @IBOutlet var noteTable: UITableView!
    
    var notes: [Note] = []
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Get notes in storage
        notes = fetchNotes()
        
    }
    
    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 1
    }

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return notes.count
    }

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        // Get the cell object
        let cell = tableView.dequeueReusableCellWithIdentifier("noteCell", forIndexPath: indexPath)
        // Set the cells text label equal to our note text
        cell.textLabel?.text = notes[indexPath.row].note
        return cell
    }
    
    override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        return true
    }
    
    override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
        if (editingStyle == UITableViewCellEditingStyle.Delete) {
            
            // Remove deleted note
            notes[indexPath.row].delete()
            notes.removeAtIndex(indexPath.row)
            // Remove from table
            noteTable.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Left)
        }
    }
    
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Pass the note object of the selected row to the edit view controller
        if (segue.identifier == "edit") {
            let destination = segue.destinationViewController as? EditViewController;
            let cell = sender as! UITableViewCell
            let selectedRow = tableView.indexPathForCell(cell)!.row
            destination!.selectedValue = notes[selectedRow]
        }
    }
    
}









{'fraction_non_alphanumeric': 0.07800345721694037, 'fraction_numerical': 0.00432152117545376, 'mean_word_length': 2.5041635124905373, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3379701', 'n_tokens_mistral': 1315, 'n_tokens_neox': 1204, 'n_words': 340}