I have a two class. Whenever I get the value of the textfield it prints nothing and if I get rid of unwrap symbol it prints optional(""). How can I solve this?
This is my code:
class userRegistration: UIViewController, UICollectionViewDelegateFlowLayout, UICollectionViewDataSource {
// in faction cell for item at index path i have this code
function collectionView(..){
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cellid", for: indexPath) as! registerNewUser
cell.registerButton.addTarget(self, action: #selector(click), for: .touchUpInside)
return cell
}
@objc func click()
{
let object = registerNewUser()
let email = object.newEmailTextField.text!
print(email)
}
}
This is done programmatically and in Swift 4.