             return nil
         }
     }
-
+    
     public class func get(objectID: NSManagedObjectID, context: NSManagedObjectContext = CoreDataManager.sharedInstance.mainContext) -> NSManagedObject? {
         return context.existingObjectWithID(objectID, error: nil)
     }
 
     public class func count(predicate: NSPredicate, context: NSManagedObjectContext = CoreDataManager.sharedInstance.mainContext) -> Int {
-        let request = self.fetchRequest(predicate, context: context)
+        let request = self.fetchRequest(predicate, sortDescriptors: nil, context: context)
         let count = context.countForFetchRequest(request, error: nil)
         return count
+    }
+    
+    public class func countAll(context: NSManagedObjectContext = CoreDataManager.sharedInstance.mainContext) -> Int {
+        let predicate = NSPredicate(value: true)
+        return self.count(predicate, context: context)
     }
 
     public class func insert(context: NSManagedObjectContext = CoreDataManager.sharedInstance.mainContext) -> NSManagedObject {
         return NSEntityDescription.insertNewObjectForEntityForName(self.entityName, inManagedObjectContext: context) as NSManagedObject
     }
 
-    public class func findFirstOrInsert(predicate: NSPredicate, context: NSManagedObjectContext = CoreDataManager.sharedInstance.mainContext) -> NSManagedObject {
-        let request = self.fetchRequest(predicate, context: context)
+    public class func findFirstOrInsert(predicate: NSPredicate, sortDescriptors: [NSSortDescriptor]? = nil, context: NSManagedObjectContext = CoreDataManager.sharedInstance.mainContext) -> NSManagedObject {
+        let request = self.fetchRequest(predicate, sortDescriptors: sortDescriptors, context: context)
         request.fetchLimit = 1
         if let objects = context.executeFetchRequest(request, error: nil) {
             if let object = objects.first as? NSManagedObject {

        context.deleteObject(self)
    }

    private class func fetchRequest(predicate: NSPredicate, context: NSManagedObjectContext) -> NSFetchRequest {
        let request = NSFetchRequest()
        request.entity = NSEntityDescription.entityForName(self.entityName, inManagedObjectContext: context)
        request.predicate = predicate
        return request
    }

    public class func find(predicate: NSPredicate, context: NSManagedObjectContext = CoreDataManager.sharedInstance.mainContext) -> [NSManagedObject] {
        let request = self.fetchRequest(predicate, context: context)
        if let objects = context.executeFetchRequest(request, error: nil) {
            return objects as [NSManagedObject]
        } else {
            return []
        }
    }

    public class func findFirst(predicate: NSPredicate, context: NSManagedObjectContext = CoreDataManager.sharedInstance.mainContext) -> NSManagedObject? {
        let request = self.fetchRequest(predicate, context: context)
        request.fetchLimit = 1
        if let objects = context.executeFetchRequest(request, error: nil) {
            return objects.first as NSManagedObject?

    }

    public class func delete(predicate: NSPredicate, context: NSManagedObjectContext = CoreDataManager.sharedInstance.mainContext) {
        let request = self.fetchRequest(predicate, sortDescriptors: nil, context: context)
        request.includesPropertyValues = false

        if let objects = context.executeFetchRequest(request, error: nil) {
