I'm using a pageViewController on the newest version of Xcode(SwiftUI). When I try to index my datasource it says Im unable to do that because: "Cannot assign to value: 'index' is a method" and "Cannot assign value of type 'Int' to type '(Any) -> Int'"
Code:
guard let startingViewController = detailViewControllerAt(index: currentViewControllerIndex) else { return } pageViewController.setViewControllers([startingViewController], direction: .forward, animated: true) }
func detailViewControllerAt(index: Int) -> DataViewController? {
if index >= dataSource.count || dataSource.count == 0 {
return nil
}
guard let dataViewController = storyboard?.instantiateViewController(withIdentifier: String(describing: DataViewController.self)) as? DataViewController else {
return nil
}
dataViewController.index = index
dataViewController.displayText = dataSource[index]
return dataViewController
}
}
I'm using this video as a tutorial, there is no other code written in the project, Im 17:44 in: https://www.google.com/search?sca_esv=597709555&sxsrf=ACQVn09NEQlIpK_V87flvqDZlCqLzjn4Gw:1705033257435&q=how+to+set+up+a+page+view+controller+for+albums&tbm=vid&source=lnms&sa=X&ved=2ahUKEwjG147t_9aDAxXQkokEHZqFBXAQ0pQJegQICRAB&biw=1920&bih=968&dpr=1#fpstate=ive&vld=cid:14bda130,vid:hIMRn_LdvOg,st:0
Any Help Would Be Greatly Appreciated
I'm a newer coder, I found a couple solutions to no avail, please help
try using
dataViewController.index(ofAccessibilityElement: index)instead ofdataViewController.index = index