ios - SWIFT 2 - Impossibile to pass value from UICollectionViewController to UICollectionViewCell. Found NIL -


i trying pass value uicollectionviewcontroller uicollectionviewcell. have created custom uicollectionviewcell connected cellview in storyboard. have created uilabel iboutlet.

when try send value uicollectionviewcell class error:

fatal error: unexpectedly found nil while unwrapping optional value 

which coming line:

videocell.nameusrvideo.text = "test" 

also cannot see object had in cell

any idea why?

uicollectionviewcontroller:

override func viewdidload() {      super.viewdidload()              collectionview!.registerclass(videocellclass.self, forcellwithreuseidentifier: "videocell")      }  override func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> uicollectionviewcell {          let videocell = collectionview.dequeuereusablecellwithreuseidentifier("videocell", forindexpath: indexpath) as! videocellclass          videocell.nameusrvideo.text = "test"          return videocell     } 

uicollectionviewcell:

class videocellclass: uicollectionviewcell {      @iboutlet weak var nameusrvideo: uilabel!      override init(frame: cgrect) {            super.init(frame: frame)        }      required init?(coder adecoder: nscoder) {         fatalerror("init(coder:) has not been implemented")     }  } 

you need remove line

collectionview!.registerclass(videocellclass.self, forcellwithreuseidentifier: "videocell") 

because it's replacing cell registration storyboard, has of outlet definitions, simple class registration. means cell won't unarchived storyboard when call dequeuereusablecellwithreuseidentifier , none of outlets exist.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -