uitableview - Error updating a cell with data from Parse -


in parse have class called "shouts", string value called "wall"

i need see how many "shouts" have in every "wall" using label inside cell of tableview

in tableviewcell have:

@iboutlet var newwalllabel: uilabel!  // name of wall (cell working) @iboutlet var shoutcounter: uilabel!  // using label want show number of objects have in "shouts" class same newwalllabel (that "wall" string in shouts class) 

in tableview i'm using countobjectsinbackgroundwithblock. println works, show me number of value have "testing" string in shout class in parse. need use whatever text have newwalllabel uilabel

so i've been trying while connect "(count)" shoutcounter label, creating in tableview:

  var counter:uilabel! 

then var inside func load data of wall

       var countshout = pfquery(classname: "shouts")     countshout.wherekey("wall", containsstring: "testing")             countshout.countobjectsinbackgroundwithblock { (count, _) -> void in                 if count == 0 {                     println("no shouts")                 } else {                     self.counter.text = "\(count)"                 }     } 

then when configuring cell i've used

        cell.shoutcounter.text = counter.text 

everything looks fine without errors, when build app crash "fatal error: unexpectedly found nil while unwrapping optional value" pointing @ string

        cell.shoutcounter.text = counter.text 

what i'm missing?

i can't comment on questions yet, counter nil because haven't initialized value. if exist on storyboard, shouldn't nil. perhaps can try recreate iboutlet

if trying define label programmatically, check out sample code defining uilabel.

var label:uilabel! label = uilabel(frame: cgrectmake(0, 0, 200, 21)) label.center = cgpointmake(160, 284) label.textalignment = nstextalignment.center label.text = "i'am test label" self.view.addsubview(label) 

i hope helps.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -