<commit_before>//
//  ViewController.swift
//  belly_cc
//
//  Created by <NAME> on 12/15/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import UIKit
import CoreLocation
import MapKit
import SwiftyJSON
import Alamofire

class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, CLLocationManagerDelegate {
    
    let clientID = FSClientDetails().clientID()
    let clientSecret = FSClientDetails().clientSecret()
    
    var locationManager = CLLocationManager()

    
    @IBOutlet weak var locationTableView: UITableView!
    var arrayOfLocations = [Location]()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.locationManager.delegate = self
        self.locationManager.requestWhenInUseAuthorization()
    
        setUpLocations()
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    func currentDate() -> String{
        let date = NSDate();
        var formatter = NSDateFormatter()
        formatter.dateFormat = "yyyyMMdd"
        return formatter.stringFromDate(date);
    }
    

    func setUpLocations(){
        let userLat = locationManager.location?.coordinate.latitude
        let userLong = locationManager.location?.coordinate.longitude
        var counter = 0
    
        sleep(8)
        Alamofire.request(.GET, "https://api.foursquare.com/v2/venues/search?ll=\(userLat!),\(userLong!)&client_id=\(clientID)&client_secret=\(clientSecret)&v=\(currentDate())").responseJSON { response in
            switch response.result {
            case .Success:
                if let value = response.result.value {
                    let json = JSON(value)
                    let locationsArray = json["response"]["venues"].arrayValue
                    for var i = 0; i < locationsArray.count;{
                        let locationName = locationsArray[i]["name"].stringValue
                        let locationLat = locationsArray[i]["location"]["lat"].stringValue
                        let locationLong = locationsArray[i]["location"]["lng"].stringValue
                        let locationCat = locationsArray[i]["categories"][0]["name"].stringValue
                        let locationImageUrlPrefix = locationsArray[i]["categories"][0]["icon"]["prefix"].stringValue
                        let locationImageUrlSuffix = locationsArray[i]["categories"][0]["icon"]["suffix"].stringValue
                        let newLocation = Location(name: locationName, lat: Double(locationLat)!, long: Double(locationLong)!, category: locationCat, imageUrl: "\(locationImageUrlPrefix)\(locationImageUrlSuffix)")
                        self.arrayOfLocations.append(newLocation)
                        i++
                    }

                    
                }
            case .Failure:
                print("failure")
                
            }
        }
    }
    
    public func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
    {
        return arrayOfLocations.count
    }
    
    public func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
    {
        let cell: LocationCell = locationTableView.dequeueReusableCellWithIdentifier("locationCell") as! LocationCell
        
        let locationToDipslay = arrayOfLocations[indexPath.row]
        cell.setCell(locationToDipslay.name, imageOfLocation: locationToDipslay.imageUrl, categoryOfLocation: locationToDipslay.category)
        
        return cell
    }
    
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        let location = arrayOfLocations[indexPath.row]
        
        var detailedViewController: DetailViewController = self.storyboard?.instantiateViewControllerWithIdentifier("DetailViewController") as! DetailViewController
        
        self.presentViewController(detailedViewController, animated: true, completion: nil)
    }


}
<commit_msg>json elements not appending into array<commit_after>//
//  ViewController.swift
//  belly_cc
//
//  Created by <NAME> on 12/15/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import UIKit
import CoreLocation
import MapKit
import SwiftyJSON
import Alamofire

class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, CLLocationManagerDelegate {
    
    let clientID = FSClientDetails().clientID()
    let clientSecret = FSClientDetails().clientSecret()
    
    var locationManager = CLLocationManager()

    
    @IBOutlet weak var locationTableView: UITableView!
    var arrayOfLocations = [Location]()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.locationManager.delegate = self
        self.locationManager.requestWhenInUseAuthorization()
    
        setUpLocations()
        
    }
    
    override func viewDidAppear(animated: Bool) {
        locationTableView.reloadData()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    func currentDate() -> String{
        let date = NSDate();
        var formatter = NSDateFormatter()
        formatter.dateFormat = "yyyyMMdd"
        return formatter.stringFromDate(date);
    }
    

    func setUpLocations(){
//        let myLocation = Location(name: "Place", lat: 22, long: 43, category: "Food", imageUrl: "http://nuclearpixel.com/content/icons/2010-02-09_stellar_icons_from_space_from_2005/earth_128.png")
//        arrayOfLocations.append(myLocation)
        let userLat = locationManager.location?.coordinate.latitude
        let userLong = locationManager.location?.coordinate.longitude
        var counter = 0
    
        sleep(8)
        Alamofire.request(.GET, "https://api.foursquare.com/v2/venues/search?ll=\(userLat!),\(userLong!)&client_id=\(clientID)&client_secret=\(clientSecret)&v=\(currentDate())").responseJSON { response in
            switch response.result {
            case .Success:
                if let value = response.result.value {
                    let json = JSON(value)
                    let locationsArray = json["response"]["venues"].arrayValue
                    for var i = 0; i < locationsArray.count;{
                        let locationName = locationsArray[i]["name"].stringValue
                        let locationLat = locationsArray[i]["location"]["lat"].stringValue
                        let locationLong = locationsArray[i]["location"]["lng"].stringValue
                        let locationCat = locationsArray[i]["categories"][0]["name"].stringValue
                        let locationImageUrlPrefix = locationsArray[i]["categories"][0]["icon"]["prefix"].stringValue
                        let locationImageUrlSuffix = locationsArray[i]["categories"][0]["icon"]["suffix"].stringValue
                        let newLocation = Location(name: locationName, lat: Double(locationLat)!, long: Double(locationLong)!, category: locationCat, imageUrl: "\(locationImageUrlPrefix)\(locationImageUrlSuffix)")
                        self.arrayOfLocations.append(newLocation)
                        i++
                    }

                    
                }
            case .Failure:
                print("failure")
                
            }
        }
        print(self.arrayOfLocations)
        [locationTableView.reloadData()]
    }
    
    public func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
    {
        return self.arrayOfLocations.count
    }
    
    public func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
    {
        let cell: LocationCell = locationTableView.dequeueReusableCellWithIdentifier("locationCell") as! LocationCell

        let locationToDipslay = self.arrayOfLocations[indexPath.row]
        cell.setCell(locationToDipslay.name, imageOfLocation: locationToDipslay.imageUrl, categoryOfLocation: locationToDipslay.category)
        
        return cell
    }
    
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        let location = self.arrayOfLocations[indexPath.row]
        
        var detailedViewController: DetailViewController = self.storyboard?.instantiateViewControllerWithIdentifier("DetailViewController") as! DetailViewController
        
        self.presentViewController(detailedViewController, animated: true, completion: nil)
    }


}

{'fraction_non_alphanumeric': 0.09630837312216141, 'fraction_numerical': 0.006172120647490393, 'mean_word_length': 2.5356113627007, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 2, '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': '6933265', 'n_tokens_mistral': 2329, 'n_tokens_neox': 2189, 'n_words': 437}