i need to understand why my code not return the property correctly. i work on UICollectionView i have a custom cell class
class FileCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var cellTitle: UILabel!
@IBOutlet weak var myImage: UIImageView!
var cellType = "";
}
now in my class UICollectionViewController
class FileCollectionViewController: UICollectionViewController, UITextFieldDelegate,
UICollectionViewDelegateFlowLayout{
let reuseIdentifier = "Cell"
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
//#warning Incomplete method implementation -- Return the number of sections
return 1;
}
override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
//#warning Incomplete method implementation -- Return the number of items in the section
return 5
}
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as FileCollectionViewCell
// Configure the cell
cell.backgroundColor = UIColor.blackColor()
cell.cellType = "PDF";// I set my cellType here
println(cell.cellType);// here it's ok i get my value
cell.myImage?.image = UIImage(named: "toto");
cell.cellTitle.text = "text";
return cell
}
override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath){
println("index : \(indexPath.row)");
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as FileCollectionViewCell
println(cell.cellType) // here i would like retrieve "PDF" but it's empty...
}
}
When i touch the cell the cellType is not return , empty is return ???
thank a lot