swift - Cannot call value of non-function type UIAlertAction -


i'm not sure what's wrong function. i'm trying present alert asking if user delete selected photo.

if function deletes photo returns error, show error user.

xcode failing on errorcontroller.addaction line message "cannot call value of non-function type uialertaction"

i'm using swift 2

@ibaction func deletephoto(sender: anyobject) {     let alertcontroller = uialertcontroller(title: "delete photo", message: "are sure want delete photo?", preferredstyle: .alert)     let okaction = uialertaction(title: "ok", style: .default) { uialertaction in          self.photogateway!.delete(self.photo!.id!, completion: { (witherror: bool) -> void in              if (witherror == true) {                 let errorcontroller = uialertcontroller(title: "delete failed", message: "blah", preferredstyle: uialertcontrollerstyle.alert)                 //  next line causing error                 errorcontroller.addaction(uialertaction(title: "ok", style: uialertactionstyle.default, handler: nil))                 self.presentviewcontroller(errorcontroller, animated: true, completion: nil)             } else {                 self.dismissviewcontrolleranimated(true, completion: nil)             }          })      }      let cancelaction = uialertaction(title: "cancel", style: .cancel) { uialertaction in         print("cancelled")     }      alertcontroller.addaction(okaction)     alertcontroller.addaction(cancelaction)     self.presentviewcontroller(alertcontroller, animated: true, completion: nil) } 

if take out offending line works well, user has no way of dismissing alert

fixed it. changed:

errorcontroller.addaction(uialertaction(title: "ok", style: uialertactionstyle.default, handler: nil)) 

to:

errorcontroller.addaction(uikit.uialertaction(title: "ok", style: uialertactionstyle.default, handler: nil)) 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -