ios - Swift 2: "the error is not handled" -


this question has answer here:

started

"call can throw not marked try , error not handled"

error after updated xcode 6.4 7 swift2 in "contactusobject.save()". how can fix this?

@ibaction func postcommentbtn_clicked(sender: anyobject) {       if messagetxtcomment.text.isempty  {          let alertview = uialertcontroller(title: "message field empty", message: "please enter message post", preferredstyle: .alert)         alertview.addaction(uialertaction(title: "ok", style: .default, handler: nil))         self.presentviewcontroller(alertview, animated: true, completion: nil)      }     else {          var thecomment = messagetxtcomment.text         let len = messagetxtcomment.text.utf16.count          if len > 150 {              thecomment = thecomment.substringtoindex(thecomment.startindex.advancedby(150))          }          let contactusobj = pfobject(classname: "contactusmessage")          contactusobj["username"] = pfuser.currentuser()!.username         contactusobj["email"] = pfuser.currentuser()!.valueforkey("email") as! string         contactusobj["name"] = namefield.text         contactusobj["enteredemail"] = emailfield.text         contactusobj["phonenum"] = phonefield.text         contactusobj["message"] = thecomment          contactusobj.save()       }   } 

do {      try contactusobj.save() } catch error nserror {     print(error)     //handle error. } 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -