progammingBeignner
progammingBeignner

Reputation: 936

How to pass data without Segue to next viewController

I am using a third party SDK where it entails a viewController on it own.

So, what i do is that i just call.

PHViewController *vc = [[PHViewController alloc] init];
[self presentViewController:vc animated:YES completion:nil];

to go to the viewController.

However, i do need to pass some data to this PHViewController. How do i do that? Because if i have storyboard, i have prepareForSegue and perFormSegueWithIdentifier functions to pass data to the next viewController, but in this i don't have that.

Upvotes: 0

Views: 528

Answers (1)

jlngdt
jlngdt

Reputation: 1368

Without Storyboard:

[DestinationViewController *vc = [[DestinationViewController alloc] init];
vc.myData = toBePassedData
[self presentViewController:vc animated:YES completion:nil];

With Storyboard:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    guard let destVC = segue.destinationViewController as? DestinationViewController else {
        return
    }
    destVC.myData = self.toBePassedData
}

Above is in Swift for storyboard, but you will understand the meaning.

Upvotes: 1

Related Questions