Swift 2 to 3 Migration for prepareForSegue
Method signature is changed in swift 3.0
Replace this
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
With
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
Cannot override prepareForSegue function
In Swift 3 the signature of the method is
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
A way to figure out yourself is to comment out the entire method and retype the first few characters (prep
). Code completion will help you.
prepare(for segue: UIStoryboardSegue, sender: AnyObject?) missing in swift 3.0/Xcode 8 b6
Maybe this was a bug in Beta 6. I'm using the GM seed, and it is working:
BTW: In beta 6, the method was renamed to
prepare(for segue: UIStoryboardSegue, sender: Any?)
How to do a performSegue to a specific view in Tab Bar Controller from another view (swift 4)
with this code, you don't need segues, you can use when you push some button
let VC1 = self.storyboard!.instantiateViewController(withIdentifier: "tabBarController") as! tabBarLoginViewController
VC1.selectedIndex = 2 //this line says that the view that appears will be third of you tab bar controller
self.navigationController!.pushViewController(VC1, animated: true)
if you want to use segue use this, the segue needs to point of tab bar controller, not a view of tab bar controller
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
if (segue.identifier == "goToMain") {
let vc = segue.destination as! TabBarController
vc.selectedIndex = 2
}
}
Why is the iOS 11: self.performSegue() not working?
I found the solution to be at a completely different place (as so often).
The reason was that I had a logic in place in applicationDidBecomeActive
that was replacing the current storyboard (bad approach!) - the additional popup from the FB Kit led to a recreation of my container view controller. Thus i had self.navigationController == nil
during the call to perform the segue.
How to create a delay in Swift?
Instead of a sleep, which will lock up your program if called from the UI thread, consider using NSTimer
or a dispatch timer.
But, if you really need a delay in the current thread:
do {
sleep(4)
}
This uses the sleep
function from UNIX.
Related Topics
Get the Top Viewcontroller in iOS Swift
How to Loop Through View Outlets in a Uiviewcontroller with Swift
What Are the Differences Between Throws and Rethrows in Swift
Override Func Error in Swift 2
Swift Extension: Same Extension Function in Two Modules
Can't Programmatically Change Color Set in Storyboard as Color from Xcassets Catalog
What Is the Use of "Static" Keyword If "Let" Keyword Used to Define Constants/Immutables in Swift
Thread Safe Singleton in Swift
Break a Number Up to an Array of Individual Digits
Aws Cognito Swift Credentials Provider "Logins Is Deprecated: Use Awsidentityprovidermanager"
Why Use Required Initializers in Swift Classes
Can the Height of the Uisearchbar Textfield Be Modified
String Convert to Int and Replace Comma to Plus Sign
How to Use a @Fetchrequest with the New Searchable Modifier in Swiftui