Reputation: 2396
I currently have this code:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
print("Being called: PrepareForSegue")
if(segue.identifier == "FBLoggedInSegue"){
print("Identifier: FBLoggedInSegue")
let nextVC = (segue.destinationViewController as? FBFriendsController)!
nextVC.accessToken = FBSDKAccessToken.currentAccessToken()
print("Niks gebeurd")
}
}
The console actually shows all of the print statements within my if statement. Unfortunately, the prepareForSegue will not open the FBFriendsController
.
This is the code I am running in the viewDidLoad()
function.
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
if (FBSDKAccessToken.currentAccessToken() != nil) {
self.performSegueWithIdentifier("FBLoggedInSegue", sender: self)
}
}
Upvotes: 0
Views: 94
Reputation: 136
Make sure you are 100% certain of segue.identifier: Modify print("Identifier: FBLoggedInSegue")
to display the actual identifier, otherwise you are working off assumptions.
Have you set the ID on the view you wish to segue to or or the actual segue line in the Interface Builder?
Hope this helps :)
EDIT:
Do this:
let vc : YourViewController
storyboard.instantiateViewControllerWithIdentifier("FBLoggedInSegue") as
YourViewController
vc.accessToken = FBSDKAccessToken.currentAccessToken()
self.presentViewController(vc, animated: true, completion:nil)
It seems the issue was present as the view controller was not getting allocated :)
Upvotes: 1