         return fromStoryboard(UIStoryboard(name: name, bundle: nil))
     }
     public class func fromStoryboard(storyboard: UIStoryboard) -> Self? {
-        return cast(fromStoryboard(storyboard, identifier: className))
-    }
+        return controllerFromStoryboard(storyboard)
+    }
+}
+
+private func controllerFromStoryboard<T: UIViewController>(storyboard: UIStoryboard) -> T? {
+    return T.fromStoryboard(storyboard, identifier: T.className) as? T
 }
 
 // MARK: NSCoding

        set { collectionViewLayout = newValue }
    }
    
    public func dequeueReusableCellForIndexPath<T: UICollectionViewCell>(indexPath: NSIndexPath!) -> T! {
        let cell = dequeueReusableCellWithReuseIdentifier(T.cellIdentifier, forIndexPath: indexPath)
        return cast(cell)!
    }
    
    public func dequeueReusableCellOfClass<T: UICollectionViewCell>(cellClass: T.Type, forIndexPath indexPath: NSIndexPath!) -> T {
        return dequeueReusableCellForIndexPath(indexPath)
    }
}


    }
    
    public func dequeueReusableCell<T: UITableViewCell>() -> T? {
        return dequeueReusableCellWithIdentifier(T.cellIdentifier) as? T
    }
    
    public func dequeueReusableCellForIndexPath<T: UITableViewCell>(indexPath: NSIndexPath) -> T {
        return dequeueReusableCellWithIdentifier(T.cellIdentifier, forIndexPath: indexPath) as! T
    }
}

