TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Jan 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Chijioke Ndubisi.
CJNibSegue is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "CJNibSegue"
Create an Enum that conforms to CJNibSegueIdentifiable
- a protocol composed of RawRepresentable
, Hashable
// Step 1
// Making the enum a string makes the it conform to RawRepresentable and Hashable
enum ChatSegueIdentifiers: String, CJNibSegueIdentifiable {
case chat
case call
}
A source view controller must
CJNibViewController
and implement nibSegue: [NibSegue]?
to return all possible segues from this source view controller// Comform to CJNibViewController
extension SourceViewController: CJNibViewController {
var nibSegue: [NibSegue]? {
return [
{
let destination = ChatViewController()
return CJNibSegue(identifier: ChatSegueIdentifiers.chat,
source: self,
destination: destination)
}()// call function immediately to return a NibSegue
]
}
(Optional)
func prepare(for nibSegue: NibSegue, sender: Any?) {
if let segue = nibSegue as? CJNibSegue<SegueIdenifiers, FirstViewController, SecondViewController>
{
switch segue.nibIdentiifer {
case .chat:
// set up detination
}
}
}
}
Call performSegue(withIdentifier: .chat,sender: cell)
All are well come via github issues
Chijioke Ndubisi, [email protected]
CJNibSegue is available under the MIT license. See the LICENSE file for more info.