Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Swift Parse problem with prepareForSegue

I have a problem with the following code. I get the error: "Type UIStoryboardSegue does not conform to protocol StringLiteralConvertible" AND also the error: "Implicit use of self in closure; to make capture semantics explicit"

Can anyone help me, with what to do here?

@IBAction func loginTapped(sender: UIButton) { PFUser.logInWithUsernameInBackground(usernameLabel.text, password: passwordLabel.text) { (user: PFUser!, error: NSError!) -> Void in if user != nil { prepareForSegue("showLoggedinSegue", sender: self) } else { println("Error") } } }

Its hard to help with it written out like this, can you post it again in code format and what is the identifier for the segue? the story board identifier?

3 Answers

It works with this code: self.performSegueWithIdentifier("loginSegue", sender: self)

Did you try turning it off and back on?

-apple support

I'll try again with the code :-)

@IBAction func loginTapped(sender: UIButton) {
        PFUser.logInWithUsernameInBackground(usernameLabel.text, password: passwordLabel.text) {
            (user: PFUser!, error: NSError!) -> Void in
            if user != nil {
                prepareForSegue("showLoggedinSegue", sender: self)
            } else {
                println("Error")
            }
        }
    }

The identifier is "showLoggedinSegue"