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

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -