<commit_before>//
//  APIFriendsAttending.swift
//  im-in-ios
//
//  Created by <NAME> on 8/16/14.
//  Copyright (c) 2014 <NAME>. All rights reserved.
//

import Foundation<commit_msg>add attending view<commit_after>//
//  APIController.swift
//  helloworld
//
//  Created by <NAME> on 2014-08-14.
//  Copyright (c) 2014 <NAME>. All rights reserved.
//

import Foundation

protocol APIFriendsAttendingControllerProtocol {
    func didReceiveAPIResults(results: NSDictionary)
}

class APIFriendsAttendingController {
    
    var delegate: APIFriendsAttendingControllerProtocol?
    
    init() {
        
    }
    
    func loadAllEvents() {
        println("APIFriendsController#loadAllEvents")
        let urlPath = "http://localhost:3000/events/1/friends_attending.json"
        let url: NSURL = NSURL(string: urlPath)
        let session = NSURLSession.sharedSession()
        let task = session.dataTaskWithURL(url, completionHandler: {data, response, error -> Void in
            println("Task completed")
            if(error) {
                // If there is an error in the web request, print it to the console
                println(error.localizedDescription)
            }
            var err: NSError?
            var jsonResult = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: &err) as NSDictionary
            if(err != nil) {
                // If there is an error parsing JSON, print it to the console
                println("JSON Error \(err!.localizedDescription)")
            }
            self.delegate?.didReceiveAPIResults(jsonResult) // THIS IS THE NEW LINE!!
        })
        task.resume()
    }
    
}
{'fraction_non_alphanumeric': 0.10071090047393365, 'fraction_numerical': 0.015402843601895734, 'mean_word_length': 2.3511904761904763, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, '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': '7656302', 'n_tokens_mistral': 504, 'n_tokens_neox': 467, 'n_words': 123}