Imaij Imaij - 2 months ago 12
Swift Question

iOS segue.destinationViewController doesn't send information

I'm working on a storyboard app with the Spotify API. I used this (https://github.com/avazquezpr/SpotifyDemo) Github project as 'base'. But the thing is; this isn't a storyboard app. After you connect with Spotify, you will directly go to the Spotify player.

I prefer:


connect spotify (ViewController) --> choose a playlist
(PlaylistController) --> go to player (PlayController)


The app is getting the login information at the
ViewController
and send them to the player. But in my case, the information must be sent through the
playlistMenuController
. But I think, there's something wrong with the
segue.destinationviewcontroller
.

ViewController
:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "goToPlaylistMenu" {

let destinationViewController: PlaylistController = segue.destinationViewController as! PlaylistController

// Send current Spotify Session
destinationViewController.currentSession = loginSession
}
}


PlaylistController
:

lazy var currentSession = SPTSession()
var loginSession = SPTSession()

override func viewDidLoad() {
super.viewDidLoad()
}


// NAVIGATION
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "goToPlayer" {

let destinationViewController: PlayerController = segue.destinationViewController as! PlayerController

destinationViewController.currentSession = loginSession
}
}


}

Answer

Got the solution, just changed

destinationViewController.currentSession = loginSession

to

destinationViewController.currentSession = currentSession

and deleted the var loginsession in the PlaylistController.

Comments