noob error on my code, how to fix it?

Hi guys i'm new to swift programming and i'm trying to create an app for testing using firebase.
I wrote this code and i get just one error on line 90 of my code here on pastebin:


https://pastebin.com/vHCzE2rM



the error says

cannot convert value of type ('String -> UIViewController' to expected argument type 'UIViewController'

basically the problem is that "vc"...

how can i easily fix it?

pls i really need to solve the problem.


thanks a lot for your time 🙂

anyone? pls it's urgent guys. i posted this question on different forums without getting an answer....

There is a line break between the name of the "instantiateViewController" method/function and the parenthesized arguments, so you are assigning the method/function to your variable, not the result.


That is what the error message is telling you; the type of vc is a function with type (String) -> UIViewController, not an actual UIViewController.



                              let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController   
                                (withIdentifier: "userVC")
                             
                                self.present(vc, animated: true, completion: nil)

For my understanding : how is it compiler does not complain with line 88 :

(withIdentifier: "userVC")


How does it interpret this ? As a String declaration ?


If I write let x = (withIdentifier: "userVC"), x is a String "userVC";

what is thus the meaning of (withIdentifier:

I'm assuming the original poster was programming in a Playground, where you can include simple inline calculations just to display the output. Unfortunately, the arguments to a function can be interpreted as a tuple, and the output just mirrors the value.


Like you, I would expect it to be treated as an error in a regular Swift file in Xcode, but can't check at the moment.

I checked in code, and it compîles and works ! (Swift 2.2)


        (withIdentifier: "userVC")
        let x = (withIdentifier: "userVC")
        Swift.print(x)


on console "userVC"


Edited : it's interpreted as a tuple with a single item.

I tried :

        let x = (withIdentifier: "userVC", withSecond: "Second")
        Swift.print(x)

and get :

("userVC", "Second")


I guess it should not work anymore in Swift4

It does cause an "Expression of type ____ is unused" warning in Xcode 8.1 (Swift 3.?) in a Swift file when an unused tuple (or literal) is on a line by itself.

noob error on my code, how to fix it?
 
 
Q