https://github.com/bannzai/segueaddition
Easily way to write perfromSegueWithIdentifier.
https://github.com/bannzai/segueaddition
Last synced: about 1 year ago
JSON representation
Easily way to write perfromSegueWithIdentifier.
- Host: GitHub
- URL: https://github.com/bannzai/segueaddition
- Owner: bannzai
- License: mit
- Created: 2016-04-18T14:34:42.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2018-08-30T00:10:44.000Z (almost 8 years ago)
- Last Synced: 2025-04-06T05:00:02.652Z (about 1 year ago)
- Language: Swift
- Homepage:
- Size: 25.4 KB
- Stars: 44
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## SegueAddition
Easily way to write perfromSegue(withIdentifier:sender).
## Usage
You can call `performSegue` with closure.
```swift
let customString = "CustomString"
performSegue("SegueIdentfiier") { segue in
guard let toViewController = segue.destinationViewController as? CustomViewController else {
fatalError()
}
toViewController.string = customString
}
```
It has the same meaning.
```swift
...
let customString = "CustomString"
performSegueWithIdentifier("SegueIdentfiier", sender: customString)
...
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
guard let toViewController = segue.destinationViewController as? CustomViewController,
customString = sender as? String
where segue.identifier == "SegueIdentfiier"
else {
fatalError()
}
toViewController.string = customString
}
```
So, no need to write `prepare(for segue: UIStoryboardSegue, sender: Any?)` again.
And, It is read and write easy for perform segue event and passing value to next view controller.
## LICENSE
[SegueAddition](https://github.com/bannzai/SegueAddition) is released under the MIT license. See LICENSE for details.