<commit_before>//
//  FetchRequestController.swift
//  AlecrimCoreData
//
//  Created by <NAME> on 11/03/18.
//  Copyright © 2018 Alecrim. All rights reserved.
//

import Foundation
import CoreData

public final class FetchRequestController<Entity: ManagedObject> {
    
    public let rawValue: NSFetchedResultsController<Entity>
    
    public init(fetchRequest: FetchRequest<Entity>, context: ManagedObjectContext, sectionNameKeyPath: String? = nil, cacheName: String? = nil) {
        self.rawValue = NSFetchedResultsController(fetchRequest: fetchRequest.rawValue, managedObjectContext: context, sectionNameKeyPath: sectionNameKeyPath, cacheName: cacheName)
        
        try! self.rawValue.performFetch()
    }
    
}
<commit_msg>Added some comments why FetchRequestController is not a subclass of NSFetchedResultsController<commit_after>//
//  FetchRequestController.swift
//  AlecrimCoreData
//
//  Created by <NAME> on 11/03/18.
//  Copyright © 2018 Alecrim. All rights reserved.
//

import Foundation
import CoreData

//
// we cannot inherit from `NSFetchedResultsController` here because the error:
// "inheritance from a generic Objective-C class 'NSFetchedResultsController' must bind type parameters of
// 'NSFetchedResultsController' to specific concrete types"
// and
// `FetchRequestController<Entity: ManagedObject>: NSFetchedResultsController<NSFetchRequestResult>` will not work for us
// (curiously the "rawValue" inside our class is accepted to be `NSFetchedResultsController<Entity>`)
//

public final class FetchRequestController<Entity: ManagedObject> {
    
    public let rawValue: NSFetchedResultsController<Entity>
    
    public init(fetchRequest: FetchRequest<Entity>, context: ManagedObjectContext, sectionNameKeyPath: String? = nil, cacheName: String? = nil) {
        self.rawValue = NSFetchedResultsController(fetchRequest: fetchRequest.rawValue, managedObjectContext: context, sectionNameKeyPath: sectionNameKeyPath, cacheName: cacheName)
        
        try! self.rawValue.performFetch()
    }
    
}

{'fraction_non_alphanumeric': 0.08712677435144396, 'fraction_numerical': 0.00978952520802741, 'mean_word_length': 4.479892761394102, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, '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': '3224191', 'n_tokens_mistral': 583, 'n_tokens_neox': 557, 'n_words': 157}