I am trying to print the cell.image.text
from collection view cell.
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell
{
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! CollectionViewCell
let post = self.arrayOfDetails[indexPath.row]
cell.currentUserLabel.text = post.username
cell.imageText.text = post.text
cell.uploadedTimeLabel.text = post.CreatedAt.timeAgo
cell.imageView.setImageWithUrl(NSURL(string: post.image)!, placeHolderImage: UIImage(named: "Placeholder"))
return cell
}
ArrayOfDetails:
var arrayOfDetails = [Details]()
Details:
struct Details {
var username:String!
var text:String!
var CreatedAt:NSDate!
var image:String!
init(username:String,text:String,CreatedAt:NSDate,image:String){
self.username = username
self.text = text
self.CreatedAt = CreatedAt
self.image = image
}
}
This is like a Instagram app, so there are multiple cells with photos and photo text, and i have a button, and when the button is pressed, it want to println(cell.image.text)
. How can i do this?
I tried:
@IBAction func printButton(sender: AnyObject) {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: nil) as! CollectionViewCell
println(cell.imageText.text)
}
But it did not show any text.