Skip to content

Instantly share code, notes, and snippets.

@bobgodwinx
Last active October 26, 2015 16:25
Show Gist options
  • Save bobgodwinx/2e43794f9c4b75a636fa to your computer and use it in GitHub Desktop.
Save bobgodwinx/2e43794f9c4b75a636fa to your computer and use it in GitHub Desktop.
IndexPath For UITextField
protocol cellIndexPathForUITextFieldDelegate:class {
var cellIndexPath: NSIndexPath? {get set}
}
extension UITextField: cellIndexPathForUITextFieldDelegate {
private struct AssociatedKeys {
static var kNSIndexPath = "kNSIndexPath"
}
var cellIndexPath: NSIndexPath? {
get{
return objc_getAssociatedObject(self, &AssociatedKeys.kNSIndexPath) as? NSIndexPath
}
set (newValue){
objc_setAssociatedObject(self, &AssociatedKeys.kNSIndexPath, newValue, .OBJC_ASSOCIATION_ASSIGN)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment