I cannot understand why some values are well passed from the tableViewController to my custom UITableViewCell, and some others are not.
In my UItableviewController.cellForRowAtIndexPath i set up a cell with some values, before returning this cell :
cell.label1.text = myCustomObject.id
cell.label2.text = myCustomObject.path
cell.myCustomObjectCellMember = myCustomObject
cell.pathCellMember = myCustomObject.path
return cell
On the custom UITableViewCell side, in awakeFromNib method, the two first cell members are Ok, the two last ones contain nil.
The only difference between the two first cell members and the two last ones is that the two first are declared as IBOutlet and linked to the storyboard, while the two others are not linked to the UI. But yet, it should be OK to write in these vars from the tableViewController, right ?
Here are the declarations of these variables in the custom UITableViewCell:
@IBOutlet weak var label1: UILabel!
@IBOutlet weak var label2: UILabel!
var pathCellMember : String!
var myCustomObjectCellMember: MyCustomObjectCellMember!
When logged (inside UITableViewCell.awakeFromNib), label1.text and label2.text show the correct value,
but pathCellMember and myCustomObjectCellMember display nil instead of the value assigned in UItableviewController.cellForRowAtIndexPath.
As requested, a more explicit code :
class CustomCellTableViewCell: UITableViewCell {
@IBOutlet weak var label1: UILabel!
@IBOutlet weak var label2: UILabel!
var pathCellMember : String!
var myCustomObjectCellMember: MyCustomObjectCellMember!
override func awakeFromNib() {
super.awakeFromNib()
println("label1 : \(self.label1.text!)") //displays the value assigned
println("label2 : \(self.label2.text!)") //displays the value assigned
println("pathCellMember: \(self.pathCellMember!)") //displays nil
println("myCustomObjectCellMember.path : \(self.myCustomObjectCellMember.path)") //displays `nil`
}
Thank you
awakeFromNibcode and specify where exactly it is being called?cellvalues incellForRowAtIndexPath, not insideawakeFromNib.tableView(_:willDisplayCell:forRowAtIndexPath:)instead oftableView(_:cellForRowAtIndexPath:)or going back to usingUITapGestureRecognizers and asking another question (that should be easily solvable).