0

I want to set property value, but getting the error "Cannot assign to the result of this expression".

let operationPageViewController:UIPageViewController = UIPageViewController(transitionStyle: UIPageViewControllerTransitionStyle.Scroll, navigationOrientation: UIPageViewControllerNavigationOrientation.Horizontal, options: nil)
operationPageViewController.viewControllers = ["firstViewController","secondViewController"]

This property is inaccessible or did I do something wrong?

Konstantin Cherkasov
  • 3,243
  • 2
  • 18
  • 22
  • 2
    `func setViewControllers(viewControllers: AnyObject[]!, direction: UIPageViewControllerNavigationDirection, animated: Bool, completion: ((Bool) -> Void)!)` – Christian Dietrich Jun 13 '14 at 22:30

1 Answers1

1

As Christian wrote in the comment, you are supposed to give other arguments like direction, animated, and completion. You need to also make sure that the view controllers that you send are UIViewcontrollers, not string.

func setViewControllers(viewControllers: AnyObject[]!, direction: UIPageViewControllerNavigationDirection, animated: Bool, completion: ((Bool) -> Void)!)
Enrico Susatyo
  • 19,372
  • 18
  • 95
  • 156
  • I wanted to make string array with identifiers of ViewControllers, but property .viewControllers was already taken. So option with string array doesn't work in Swift? I mean exactly with .viewControllers property. – Konstantin Cherkasov Jun 13 '14 at 22:56
  • You want to make string array with identifiers of view controllers that you already have in your UIPageViewControllers? Then you don't want to use the setters in this case. – Enrico Susatyo Jun 13 '14 at 23:01
  • I want to load them dynamically, so UIPageViewController don't have any identifiers. But I think, that I must try your option too. Probably it's even better. Here is example of what I am trying to do. http://stackoverflow.com/questions/21641373/how-to-implement-uipageviewcontroller-that-utilizes-multiple-viewcontrollers – Konstantin Cherkasov Jun 13 '14 at 23:10