1

How do I get the item value from the cole below?

let pointInTable: CGPoint = sender.convertPoint(sender.bounds.origin, toView: self.collectionView)
let cellIndexPath = self.collectionView?.indexPathForItemAtPoint(pointInTable)
println(cellIndexPath)

I am currently shown this but need the integer value.

Optional(<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 1})
Tom Coomer
  • 6,227
  • 12
  • 45
  • 82
  • 1
    What "integer value"? What part of that log message do you not understand? You don't know what an NSIndexPath is? You don't know what an Optional is? What's the problem here? – matt Oct 29 '14 at 15:15

2 Answers2

1

You can extract the row from a NSIndexPath.

NSIndexPath.row.

You have to determine yourself the number corresponding to a defined NSIndexPath. NSIndexPath contains row and col coordinates.

David Ansermot
  • 6,052
  • 8
  • 47
  • 82
0

I managed to get what I needed by using the line below:

cellIndexPath?.item
JAL
  • 41,701
  • 23
  • 172
  • 300
Tom Coomer
  • 6,227
  • 12
  • 45
  • 82