ios - Could not find an overload for 'subscript' that accepts the supplied arguments - When convert Swift 1.2 to 2 -
i'm converting project swift 1.2 2. following code:
func pagecontrolchanged(pagecontrol: uipagecontrol) { // current , upcoming page numbers let currenttutorialpage = (viewcontrollers[0] as! partystepviewcontroller).page let upcomingtutorialpage = pagecontrol.currentpage // direction moving in? let direction: uipageviewcontrollernavigationdirection = upcomingtutorialpage < currenttutorialpage ? .reverse : .forward // set new page, animated! setviewcontrollers([partystepforpage(upcomingtutorialpage)], direction: direction, animated: true, completion: nil) } gave me following error:
could not find overload 'subscript' accepts supplied arguments
for particular line of code:
let currenttutorialpage = (viewcontrollers[0] as! partystepviewcontroller).page what error message mean? how can fix it?
here links code:
- a zipfile of whole project, not converted swift 2
partystepviewcontrollerpartypagedviewcontroller
the problem viewcontrollers is optional.
so have unwrap before can subscript it: viewcontrollers![0]
Comments
Post a Comment