Skip to content

Instantly share code, notes, and snippets.

@justinmakaila
Last active August 29, 2015 14:14
Show Gist options
  • Save justinmakaila/33ec25a5528737855b92 to your computer and use it in GitHub Desktop.
Save justinmakaila/33ec25a5528737855b92 to your computer and use it in GitHub Desktop.
NibView
import UIKit
// MARK: - Nib Views
/**
A protocol to be implemented by all views that implement their
presentation through a `.xib`.
*/
protocol NibView {
/**
:returns: UINib instance representing the view.
*/
class func nib() -> UINib
}
/**
A protocol to be implemented by views that can be reused and
supply their own reuse identifier.
*/
protocol ReuseIdentifierProtocol {
/**
:returns: String reuse identifier to be registered with the view.
*/
class func reuseIdentifier() -> String
}
protocol ReusableViewKind {
/*
Must return UICollectionElementKindSectionHeader or UICollectionElementKindSectionFooter
*/
class func reusableKind() -> String
}
// MARK: - Table View Cells
/**
Provides a protocol which combines NibView and ReuseIdentifierProtocol
as a convenience for table view cells.
*/
protocol CellNibView: NibView, ReuseIdentifierProtocol { }
/**
Protocol to be implemented by any view which can be reused
by UITableView or UICollectionView.
*/
protocol ReusableNibView: NibView, ReuseIdentifierProtocol { }
protocol ReusableNibViewKind: ReusableNibView, ReusableViewKind { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment