swift - New Xcode 7.3 error - Ambiguous us of 'view' -


the following code worked prior upgrading xcode 7.3;

func mymethod() {

            let tapgesture = uitapgesturerecognizer(target: self, action: #selector(createbuttonobject.notifybuttonaction(_:)))             let longpressgesture = uilongpressgesturerecognizer(target: self, action: #selector(createbuttonobject.notifybuttonaction(_:)))             tapgesture.numberoftapsrequired = 1 

}

@ibaction @objc func notifybuttonaction (sender: anyobject) {      let userinfo:dictionary<string,anyobject!>     print("sender tap or longpress: \(sender)")     **let button = sender.view as! uibutton**     let soundname = button.currenttitle!      userinfo = ["sender" : sender]      nsnotificationcenter.defaultcenter().postnotificationname(sleepezbuttonactionnotificationkey, object: nil, userinfo: userinfo)      ddlogdebug("createbuttonobject.notifybuttonaction: notificaiton! buttonviewcontroller")     ddlogdebug("createbuttonobject.notifybuttonaction: posted notification sleepezbuttonactionnotificationkey initiate buttonaction")     ddlogdebug("createbuttonobject.notifybuttonaction: button name: \(soundname)")     ddlogdebug("") } 

but when in xcode 7.3 following error on line sender.view ; ambiguous use of 'view'

followed compiler error.

anyone know what's going on here , how fix. can't figure out. need uibutton attributes out of uitapgesurerecognizer object created , activated on button press. stuck.

thanks in advance...

in declaration func notifybuttonaction (sender: anyobject), have typed sender anyobject. anyobject doesn't have view. in line sender.view as! uibutton, phrase sender.view illegal.

type sender uigesturerecognizer if that's is: func notifybuttonaction (sender: uigesturerecognizer). gesture recognizer have view, well.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -