swift - Subclassing SLKTextViewController -


i have viewcontroller tableview runs correctly.

now trying subclass slktextviewcontroller app crashes. have subclassed incorrectly (following this example)?

slktextviewcontroller subclass:

import uikit  class commentstextviewcontroller: slktextviewcontroller {      var foodphotoobject: pfobject?     var usernametext = ""     var distancelabeltext = ""     var userphotouiimage: uiimage?     var mainrestaurantuiimage: uiimage?      // comment arrays     var photocommentobjects: [anyobject] = []     var commentusers: [pfuser] = []     var commenttext: [string] = []      @iboutlet var mainrestaurantimageview: pfimageview!     @iboutlet var userphoto: uiimageview!     @iboutlet var username: uibutton!     @iboutlet weak var distancelabel: uilabel!      override func viewdidload() {         super.viewdidload()          setuptableviewcells()          // load comments         fetchcomments()         self.tableview.registerclass(commentscell.self, forcellreuseidentifier: "commentcell")         self.tableview.rowheight = uitableviewautomaticdimension         self.tableview.estimatedrowheight = 80         self.tableview.backgroundcolor = uicolor.clearcolor()         self.tableview.delegate = self         self.tableview.datasource = self         self.tableview.scrollstotop = true         self.bounces = true         self.keyboardpanningenabled = true         self.inverted = true         self.tableview.frame = self.view.frame         self.textview.placeholder = "comment"         self.textview.placeholdercolor = uicolor(red: 0.75, green: 0.75, blue: 0.75, alpha: 1)         self.textview.layer.bordercolor = uicolor(red: 0.75, green: 0.75, blue: 0.75, alpha: 1).cgcolor         self.textview.pastablemediatypes = slkpastablemediatype.none         self.rightbutton.settitle("post", forstate: uicontrolstate.normal)         self.textinputbar.autohiderightbutton = true         self.textinputbar.maxcharcount = 140         self.textinputbar.counterstyle = slkcounterstyle.split //        // additional setup after loading view.     }      func setuptableviewcells() {         username.settitle(usernametext, forstate: .normal)         distancelabel.text = distancelabeltext         userphoto.image = userphotouiimage         // make profile photo circular         userphoto.layer.cornerradius = userphoto.frame.size.width / 2;         userphoto.layer.maskstobounds = true;         userphoto.layer.borderwidth = 0 // remove border          mainrestaurantimageview.image = mainrestaurantuiimage         mainrestaurantimageview.contentmode = .scaleaspectfill         mainrestaurantimageview.clipstobounds = true          tableview.estimatedrowheight = 44.0         tableview.rowheight = uitableviewautomaticdimension     }      func fetchcomments() {          var query = pfquery(classname:"activity") //default: restaurant         query.wherekey("photo", equalto:foodphotoobject!) // find photos equal         query.wherekey("type", equalto:"comment")         query.includekey("fromuser")         query.orderbydescending("createdat")         query.findobjectsinbackgroundwithblock {             (objects: [anyobject]?, error: nserror?) -> void in             if objects!.isempty { //if objects != nil {                 //no results                 println("no comments found") //allow user input zipcode                 // check if activity indicator animating                 self.stopactivityindicator()             } else {                 println(objects)                 self.photocommentobjects = objects!                  self.commentusers = self.photocommentobjects.map { $0.objectforkey("fromuser") as! pfuser }                 self.commenttext = self.photocommentobjects.map { $0.objectforkey("content") as! string }                  dispatch_async(dispatch_get_main_queue(), { () -> void in                     self.tableview.reloaddata()                 })             }         }     }      override func didreceivememorywarning() {         super.didreceivememorywarning()         // dispose of resources can recreated.     }      override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {         let cell = tableview.dequeuereusablecellwithidentifier("commentcell", forindexpath: indexpath) as! commentscell         // start: comment date         let datecreated = photocommentobjects[indexpath.row].createdat nsdate!         let dateformat = nsdateformatter()         dateformat.dateformat = "eee, mmm d, h:mm a"         dateformat.datestyle = .shortstyle         dateformat.timestyle =  .nostyle         dateformat.doesrelativedateformatting = true         cell.timelabel.text = nsstring(format: "%@", dateformat.stringfromdate(datecreated)) string         cell.commentlabel.text = commenttext[indexpath.row]         //cell.commentlabel.adjustsfontsizetofitwidth = true         cell.commentlabel.preferredmaxlayoutwidth = 300           // start: username out of pfuser array         let commentuser: pfuser = self.commentusers[indexpath.row]         let commentusername: string = commentuser.objectforkey("username") as! string          cell.username.settitle(commentusername, forstate: .normal)            // start: profile photo         // profile pffile         var getprofilephoto: pffile! = commentuser.objectforkey("profilephoto") as? pffile          // uiimage pffile         if (getprofilephoto != nil) { // if there profilephoto             getprofilephoto.getdatainbackgroundwithblock {                 (imagedata: nsdata?, error: nserror?) -> void in                 if error == nil {                     let image = uiimage(data:imagedata!)                     cell.userphoto.image = image                     println("this image3 \(image)")                      //                                self.uploadphoto.hidden = true // hide "upload photo button"                     cell.userphoto.layer.cornerradius = cell.userphoto.frame.size.width / 2;                     cell.userphoto.layer.maskstobounds = true;                     cell.userphoto.layer.borderwidth = 0 // remove border                 }             }         } else { // there no profile photo (use default              // set default profile photo             cell.userphoto.image = uiimage(named: "tasteup-icon")             cell.userphoto.layer.cornerradius = cell.userphoto.frame.size.width / 2;             cell.userphoto.layer.maskstobounds = true;             cell.userphoto.layer.borderwidth = 0 // remove border         }          return cell      }      override func tableview(tableview: uitableview, estimatedheightforrowatindexpath indexpath: nsindexpath) -> cgfloat {         return 80     }      override func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int {         return self.photocommentobjects.count     }      override func numberofsectionsintableview(tableview: uitableview) -> int {         return 1     }      override func didpressrightbutton(sender: anyobject!) {         self.textview.refreshfirstresponder()         var comment:string = self.textview.text         self.tableview.beginupdates()         self.tableview.insertrowsatindexpaths([nsindexpath(forrow: 0, insection: 0)], withrowanimation: uitableviewrowanimation.automatic)         self.tableview.endupdates()          self.tableview.scrolltorowatindexpath(nsindexpath(forrow: 0, insection: 0), atscrollposition: uitableviewscrollposition.bottom, animated: true)         super.didpressrightbutton(sender)     } } 

error:

2015-05-13 22:04:30.890 app[39965:1524334] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '*** -[__nsplaceholderdictionary initwithobjects:forkeys:count:]: attempt insert nil object objects[0]' *** first throw call stack: (     0   corefoundation                      0x0000000110e77c65 __exceptionpreprocess + 165     1   libobjc.a.dylib                     0x000000011366abb7 objc_exception_throw + 45     ...     24  uikit                               0x000000011239e900 uiapplicationmain + 1282     25  tasteup                             0x000000010fdbf077 main + 135     26  libdyld.dylib                       0x00000001159ab145 start + 1 ) libc++abi.dylib: terminating uncaught exception of type nsexception 

you need import slacktextviewcontroller


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -