 	
 	//MARK: -
 	
-	public subscript(indexPath:NSIndexPath) -> NSManagedObject {
-		return self.fetchedResults.objectAtIndexPath(indexPath) as NSManagedObject
+	public subscript(indexPath:NSIndexPath) -> D.ManagedObject {
+		return self.fetchedResults.objectAtIndexPath(indexPath) as D.ManagedObject
 	}
 	
-	public subscript(object:NSManagedObject) -> NSIndexPath? {
+	public subscript(object:D.ManagedObject) -> NSIndexPath? {
 		return self.fetchedResults.indexPathForObject(object)
 	}
 	

		}
	}
	
	public func controller(controller:NSFetchedResultsController, didChangeObject object:NSManagedObject, atIndexPath indexPath:NSIndexPath!, forChangeType type:NSFetchedResultsChangeType, newIndexPath:NSIndexPath!) {
		
		switch type {
			case .Insert: self.delegate?.dataSource(self, didInsert:object, at:newIndexPath)

import CoreData


public protocol DataSourceDelegate : class {
	
	typealias Associate
	typealias ManagedObject
	
	func dataSourceWillChangeContent(dataSource:DataSource<Self>)
	func dataSourceDidChangeContent(dataSource:DataSource<Self>)
	
	func dataSource(dataSource:DataSource<Self>, didInsert section:Int)
	func dataSource(dataSource:DataSource<Self>, didDelete section:Int)
	
	func dataSource(dataSource:DataSource<Self>, didInsert object:ManagedObject, at indexPath:NSIndexPath)
	func dataSource(dataSource:DataSource<Self>, didDelete object:ManagedObject, at indexPath:NSIndexPath)
	func dataSource(dataSource:DataSource<Self>, didUpdate object:ManagedObject, at indexPath:NSIndexPath)
	func dataSource(dataSource:DataSource<Self>, didMove object:ManagedObject, at indexPath:NSIndexPath, to:NSIndexPath)
	
	func dataSource(dataSource:DataSource<Self>, associateFor object:ManagedObject, at indexPath:NSIndexPath) -> Associate
	func dataSource(dataSource:DataSource<Self>, shouldDelete object:ManagedObject, at indexPath:NSIndexPath)
}


//MARK: -

public class DataSource<D:DataSourceDelegate where D.ManagedObject == NSManagedObject> : NSFetchedResultsControllerDelegate {

	public weak var delegate:D?
	
	public let context:NSManagedObjectContext
	public let request:NSFetchRequest
