ios - Any can not be used with dictionary literal -


i trying use segue context on watchkit, , ran issue:

contextual type '[any]' cannot used dictionary literal

here code using:

override func contextsforsegue(withidentifier segueidentifier: string) -> [any]? {      if segueidentifier == "one" {         return ["scenename" : "one"]     } else if segueidentifier == "two" {         return ["scenename": "two"]     } else {         return ["scenename": "three"]     } } 

on segue destination there's code, produces no errors:

@iboutlet var thename: wkinterfacelabel!  override func awake(withcontext context: any?) {     super.awake(withcontext: context)     // configure interface objects here.     self.settitle("")     let dict = context as? nsdictionary     if dict != nil {         let seguecontext = dict![["scenename"]] as! string         thename.settext(seguecontext)     } } 


hope can help!

the return type needs array of objects, while trying return single dictionary literal.

the function trying override used send context array of page based interface controllers. sure, trying do? code, seems like, should overriding function contextforsegue(withidentifier segueidentifier: string) -> any?.

override func contextforsegue(withidentifier segueidentifier: string) -> any? {      if segueidentifier == "one" {         return ["scenename" : "one"]     } else if segueidentifier == "two" {         return ["scenename": "two"]     } else {         return ["scenename": "three"]     } } 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -