共享实例和全局变量

时间:2017-05-20 06:46:57

标签: ios swift xcode spotify

我正在使用Spotify SDK并遵循本教程中的说明:https://medium.com/@elonrubin/ios-spotify-sdk-swift-3-0-tutorial-b629af4b889d 本指南使用此功能初始化SpotifyPlayer:

func initializeSpotifyPlayer(authSession:SPTSession){
    if self.spotifyPlayer == nil {
        self.spotifyPlayer = SPTAudioStreamingController.sharedInstance()
        self.spotifyPlayer!.playbackDelegate = self
        self.spotifyPlayer!.delegate = self
        try! spotifyPlayer!.start(withClientId: auth.clientID)
        self.spotifyPlayer!.login(withAccessToken: authSession.accessToken)
    }
}

在第三行,您可以看到它使SpotifyPlayer成为共享实例。如何从另一个ViewController /文件访问同一个spotifyPlayer?

0 个答案:

没有答案