<commit_before>//
//  SectionsViewModel.swift
//  Schnell
//
//  Created by <NAME> on 07/06/14.
//  Copyright (c) 2014 <NAME>. All rights reserved.
//

import Foundation
import SchnellKit

class SectionsViewModel {
    var sections = [RoadSection]()
    var isActivated = false
    
    func activate() {
        self.isActivated = true
        
        let reponseData = NSData(contentsOfFile: NSBundle.mainBundle().pathForResource("sections", ofType: "json"))
        let error: NSErrorPointer?
        
        if let response = NSJSONSerialization.JSONObjectWithData(reponseData, options: NSJSONReadingOptions(), error: error!) as? NSDictionary {
            if let result = response["result"] as? NSDictionary {
                if let records = result["records"] as? NSArray {
                    for (var i = 0; i < records.count; i++) {
                        let record = records[i] as NSDictionary
                        let roadSection = RoadSection(data:record)
                        sections.append(roadSection)
                    }
                }
            }
        }        
    }
}<commit_msg>Fixed crash regarding the akward NSJSONSerialization API.<commit_after>//
//  SectionsViewModel.swift
//  Schnell
//
//  Created by <NAME> on 07/06/14.
//  Copyright (c) 2014 <NAME>. All rights reserved.
//

import Foundation
import SchnellKit

class SectionsViewModel {
    var sections = [RoadSection]()
    var isActivated = false
    
    func activate() {
        self.isActivated = true
        
        let reponseData = NSData(contentsOfFile: NSBundle.mainBundle().pathForResource("sections", ofType: "json"))
        
        if let response = NSJSONSerialization.JSONObjectWithData(reponseData, options: nil, error: nil) as? NSDictionary {
            if let result = response["result"] as? NSDictionary {
                if let records = result["records"] as? NSArray {
                    for (var i = 0; i < records.count; i++) {
                        let record = records[i] as NSDictionary
                        let roadSection = RoadSection(data:record)
                        sections.append(roadSection)
                    }
                }
            }
        }        
    }
}
{'fraction_non_alphanumeric': 0.09887640449438202, 'fraction_numerical': 0.009887640449438202, 'mean_word_length': 1.842911877394636, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '6333409', 'n_tokens_mistral': 621, 'n_tokens_neox': 582, 'n_words': 159}