Created
June 15, 2016 10:47
-
-
Save dtorres/514edceb72e3d81cb4530d4db7715610 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol reuseIdentifierClass { | |
static var reuseIdentifier: String { get } | |
} | |
extension UICollectionView { | |
func registerClass<T: UICollectionViewCell where T: reuseIdentifierClass>(aClass: T.Type) { | |
registerClass(aClass, forCellWithReuseIdentifier: aClass.reuseIdentifier) | |
} | |
func dequeueReusableCellWithClass<T: UICollectionViewCell where T: reuseIdentifierClass>(aClass: T.Type, forIndexPath indexPath: NSIndexPath) -> T { | |
return dequeueReusableCellWithReuseIdentifier(aClass.reuseIdentifier, forIndexPath: indexPath) as! T | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment