I have doubt in Swift 3.0
In Objective-C you can declare a property for selector
like this
@property (nonatomic,assign)SEL ItemSelected;
But how to declare a selector in Swift 3.0 as property because I would like to use this property in other class and should give action in that class.
I am trying to use it like this (Declared in tableview cell):
var itemSelected = #selector(selctedItem(_ :))
Using it in viewcontroller table view cell
cell.itemSelected(target: self, action: HomeViewController.self.selctedItem(_ :))
it's giving error
use of Undeclared item selectedItem
I am not sure how to use in tableview with selctor.
You can declare selector in Swift 3 like this.
Or
Later you can use above
itemSelected
selector with action like this.For eg:
And
tapGesture
is declared likeEdit: You have added
collectionView
inside yourTableViewCell
, so to get the selected IndexPath ofCollectionViewCell
, declare one protocol and use it with your tableViewCell.Now create one instance of SelectedCellDelegate and instance of
IndexPath
within your CustomTableViewCell.Now inside your ViewController where you have added TableView implement the protocol
SelectedCellDelegate
and set thedelegate
andtableCellIndexPath
incellForRowAt indexPath
method.Now add the delegate method in your ViewController.