<commit_before>//
//  UserCell.swift
//  TwitterClientDemo
//
//  Created by <NAME> on 5/21/15.
//  Copyright (c) 2015 kitasuke. All rights reserved.
//

import UIKit

class UserCell: UITableViewCell {
    @IBOutlet weak var profileImageView: UIImageView?
    @IBOutlet weak var nameLabel: UILabel?
    @IBOutlet weak var screenLabel: UILabel?
    private var imageCache = NSCache()
    private var queue = NSOperationQueue()
    
    internal func setup(user: User, indexPath: NSIndexPath) {
        nameLabel?.text = user.name
        nameLabel?.tag = indexPath.row
        let userViewModel = UserViewModel(user: user)
        screenLabel?.text = userViewModel.screenName
        screenLabel?.tag = indexPath.row
        
        // use image on cache, if no exists, fetch and store it on cache
        if let image = imageCache.objectForKey(indexPath) as? UIImage {
            profileImageView?.image = image
        } else {
            let request = NSURLRequest(URL: NSURL(string: user.profileImage)!)
            NSURLConnection.sendAsynchronousRequest(request,
                queue: queue,
                completionHandler: { [unowned self] (response: NSURLResponse!, data: NSData!, error: NSError!) -> Void in
                    if let image = UIImage(data: data) {
                        self.imageCache.setObject(image, forKey: indexPath)
                        dispatch_async(dispatch_get_main_queue(), { () -> Void in
                            self.profileImageView?.image = image
                            self.profileImageView?.alpha = 0
                            UIView.animateWithDuration(1.0, animations: { () -> Void in // like SDWebImage
                                self.profileImageView?.alpha = 1
                            })
                        })
                    }
            })
        }
        profileImageView?.tag = indexPath.row
        if let following = user.following {
            self.accessoryType = following ? .Checkmark : .None
        } else {<commit_msg>Fix a bug to detect cell's row<commit_after>//
//  UserCell.swift
//  TwitterClientDemo
//
//  Created by <NAME> on 5/21/15.
//  Copyright (c) 2015 kitasuke. All rights reserved.
//

import UIKit

class UserCell: UITableViewCell {
    @IBOutlet weak var profileImageView: UIImageView?
    @IBOutlet weak var nameLabel: UILabel?
    @IBOutlet weak var screenLabel: UILabel?
    private var imageCache = NSCache()
    private var queue = NSOperationQueue()
    
    internal func setup(user: User, indexPath: NSIndexPath) {
        contentView.tag = indexPath.row
        nameLabel?.text = user.name
        nameLabel?.tag = indexPath.row
        let userViewModel = UserViewModel(user: user)
        screenLabel?.text = userViewModel.screenName
        screenLabel?.tag = indexPath.row
        
        // use image on cache, if no exists, fetch and store it on cache
        if let image = imageCache.objectForKey(indexPath) as? UIImage {
            profileImageView?.image = image
        } else {
            let request = NSURLRequest(URL: NSURL(string: user.profileImage)!)
            NSURLConnection.sendAsynchronousRequest(request,
                queue: queue,
                completionHandler: { [unowned self] (response: NSURLResponse!, data: NSData!, error: NSError!) -> Void in
                    if let image = UIImage(data: data) {
                        self.imageCache.setObject(image, forKey: indexPath)
                        dispatch_async(dispatch_get_main_queue(), { () -> Void in
                            self.profileImageView?.image = image
                            self.profileImageView?.alpha = 0
                            UIView.animateWithDuration(1.0, animations: { () -> Void in // like SDWebImage
                                self.profileImageView?.alpha = 1
                            })
                        })
                    }
            })
        }
        profileImageView?.tag = indexPath.row
        if let following = user.following {
            self.accessoryType = following ? .Checkmark : .None
        } else {
{'fraction_non_alphanumeric': 0.08969047038752133, 'fraction_numerical': 0.006336826712161832, 'mean_word_length': 1.7842605156037992, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '5554877', 'n_tokens_mistral': 1122, 'n_tokens_neox': 1040, 'n_words': 280}