Shreyas Papinwar
Shreyas Papinwar

Reputation: 63

Cannot convert value of type'[AnyObject]'to expected argument type '[UIViewController]?'

private func createPageViewController() {
    let pageViewController = self.storyboard?.instantiateViewControllerWithIdentifier("PageViewController") as! UIPageViewController
    pageViewController.dataSource = self
    pageViewController.delegate = self

    if contentImages.count > 0 {
        let firstVC = self.getItemController(0)!
        let startingVCs: NSArray = [firstVC]
        pageViewController.setViewControllers(startingVCs as [AnyObject] as [AnyObject], direction: .Forward, animated: false, completion: nil)
    }

Upvotes: 0

Views: 954

Answers (1)

Anbu.Karthik
Anbu.Karthik

Reputation: 82759

change this

pageViewController.setViewControllers(startingVCs as [AnyObject] as [AnyObject], direction: .Forward, animated: false, completion: nil)

into

The viewControllers parameter is now a [UIViewController]. So your viewControllers array that you pass in must be [UIViewController].

pageViewController.setViewControllers(startingVCs as [UIViewController], direction: .Forward, animated: false, completion: nil)

Upvotes: 1

Related Questions