How can I override a Swift delegate method to take more parameters?How can I develop for iPhone using a Windows development machine?How can I disable the UITableView selection?How do I create delegates in Objective-C?How can I make a UITextField move up when the keyboard is present - on starting to edit?Why is textFieldDidEndEditing: not being called?iPhone:How to manage UITextfield delegate methods on dynamic number of customcellsHow to call Objective-C code from SwiftHow would I create a UIAlertView in Swift?UITextField custom drawing when editingDismiss the Number Pad with a custom table view cell with TextField
How does a refinance allow a mortgage to be repaid?
What do you call someone who asks many questions?
How to stretch the corners of this image so that it looks like a perfect rectangle?
Processor speed limited at 0.4 Ghz
Was the Stack Exchange "Happy April Fools" page fitting with the '90's code?
What is the most common color to indicate the input-field is disabled?
How to travel to Japan while expressing milk?
Is it possible to map the firing of neurons in the human brain so as to stimulate artificial memories in someone else?
How can a day be of 24 hours?
How to Prove P(a) → ∀x(P(x) ∨ ¬(x = a)) using Natural Deduction
Forgetting the musical notes while performing in concert
Why do I get negative height?
How to install cross-compiler on Ubuntu 18.04?
Bullying boss launched a smear campaign and made me unemployable
Sums of two squares in arithmetic progressions
Do creatures with a listed speed of "0 ft., fly 30 ft. (hover)" ever touch the ground?
Does the Idaho Potato Commission associate potato skins with healthy eating?
Can someone clarify Hamming's notion of important problems in relation to modern academia?
Getting extremely large arrows with tikzcd
One verb to replace 'be a member of' a club
How do conventional missiles fly?
How can saying a song's name be a copyright violation?
How obscure is the use of 令 in 令和?
What does the same-ish mean?
How can I override a Swift delegate method to take more parameters?
How can I develop for iPhone using a Windows development machine?How can I disable the UITableView selection?How do I create delegates in Objective-C?How can I make a UITextField move up when the keyboard is present - on starting to edit?Why is textFieldDidEndEditing: not being called?iPhone:How to manage UITextfield delegate methods on dynamic number of customcellsHow to call Objective-C code from SwiftHow would I create a UIAlertView in Swift?UITextField custom drawing when editingDismiss the Number Pad with a custom table view cell with TextField
I have a form with 3 UITextFields. I'd like to validate the user input for each field, when the user is done inputing text in that specific field. Right now, I've got a method
validateAllFields()
that I call in:
func textFieldDidEndEditing(_ textField: UITextField)
self.validateAllFields()
I'd rather validate a single field, after its text has been modified, not validate all fields after each one has been modified.
Is there a ways to override a delegate method or extend UITextField to take more parameters? Something like:
override func textFieldDidEndEditing(_ textField: UITextField,
textFieldIdentifier: TextFieldIdentifierEnum)
self.validate(textField: textField, basedOn: textFieldIdentifier)
I suspect it can be done with an extension, but I'm unclear how to proceed.
Thanks for the help!
ios swift cocoa-touch uikit
add a comment |
I have a form with 3 UITextFields. I'd like to validate the user input for each field, when the user is done inputing text in that specific field. Right now, I've got a method
validateAllFields()
that I call in:
func textFieldDidEndEditing(_ textField: UITextField)
self.validateAllFields()
I'd rather validate a single field, after its text has been modified, not validate all fields after each one has been modified.
Is there a ways to override a delegate method or extend UITextField to take more parameters? Something like:
override func textFieldDidEndEditing(_ textField: UITextField,
textFieldIdentifier: TextFieldIdentifierEnum)
self.validate(textField: textField, basedOn: textFieldIdentifier)
I suspect it can be done with an extension, but I'm unclear how to proceed.
Thanks for the help!
ios swift cocoa-touch uikit
You can't add more parameters. And there is no need. You are already told which text field is affected.
– rmaddy
Mar 7 at 21:23
add a comment |
I have a form with 3 UITextFields. I'd like to validate the user input for each field, when the user is done inputing text in that specific field. Right now, I've got a method
validateAllFields()
that I call in:
func textFieldDidEndEditing(_ textField: UITextField)
self.validateAllFields()
I'd rather validate a single field, after its text has been modified, not validate all fields after each one has been modified.
Is there a ways to override a delegate method or extend UITextField to take more parameters? Something like:
override func textFieldDidEndEditing(_ textField: UITextField,
textFieldIdentifier: TextFieldIdentifierEnum)
self.validate(textField: textField, basedOn: textFieldIdentifier)
I suspect it can be done with an extension, but I'm unclear how to proceed.
Thanks for the help!
ios swift cocoa-touch uikit
I have a form with 3 UITextFields. I'd like to validate the user input for each field, when the user is done inputing text in that specific field. Right now, I've got a method
validateAllFields()
that I call in:
func textFieldDidEndEditing(_ textField: UITextField)
self.validateAllFields()
I'd rather validate a single field, after its text has been modified, not validate all fields after each one has been modified.
Is there a ways to override a delegate method or extend UITextField to take more parameters? Something like:
override func textFieldDidEndEditing(_ textField: UITextField,
textFieldIdentifier: TextFieldIdentifierEnum)
self.validate(textField: textField, basedOn: textFieldIdentifier)
I suspect it can be done with an extension, but I'm unclear how to proceed.
Thanks for the help!
ios swift cocoa-touch uikit
ios swift cocoa-touch uikit
asked Mar 7 at 21:20
RIP.Ben.FranklinRIP.Ben.Franklin
761212
761212
You can't add more parameters. And there is no need. You are already told which text field is affected.
– rmaddy
Mar 7 at 21:23
add a comment |
You can't add more parameters. And there is no need. You are already told which text field is affected.
– rmaddy
Mar 7 at 21:23
You can't add more parameters. And there is no need. You are already told which text field is affected.
– rmaddy
Mar 7 at 21:23
You can't add more parameters. And there is no need. You are already told which text field is affected.
– rmaddy
Mar 7 at 21:23
add a comment |
1 Answer
1
active
oldest
votes
You don't have to as the paramter (_ textField: UITextField)
gives you the current textfield the user changes
Suppose you have
@IBOutlet weak var emailTexf:UITextField!
@IBOutlet weak var passTexf:UITextField!
func textFieldDidEndEditing(_ textField: UITextField)
self.validateAllFields(textField)
fun validateAllFields(_ current:UITextField)
if emailTexf == current
else if passTexf == current
else // etc
Sure, that makes sense. How do I distinguish them? In your example, you use "emailTexf" and "passTexf", but where are you getting those from? Happy to upvote and select this as the answer, if you can help me clarify that. Thanks!
– RIP.Ben.Franklin
Mar 8 at 16:36
1
you need to replace them with your own variables , above is for an example
– Sh_Khan
Mar 8 at 16:37
Can you give a more complete example that explains what you're saying? Sorry, I'm not understanding. Thank you!
– RIP.Ben.Franklin
Mar 8 at 16:38
1
It's supposed you have outlets for the textfields to validate see edit
– Sh_Khan
Mar 8 at 16:40
Oh yeah! Of course! Got it! Thanks!
– RIP.Ben.Franklin
Mar 8 at 16:47
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55052964%2fhow-can-i-override-a-swift-delegate-method-to-take-more-parameters%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You don't have to as the paramter (_ textField: UITextField)
gives you the current textfield the user changes
Suppose you have
@IBOutlet weak var emailTexf:UITextField!
@IBOutlet weak var passTexf:UITextField!
func textFieldDidEndEditing(_ textField: UITextField)
self.validateAllFields(textField)
fun validateAllFields(_ current:UITextField)
if emailTexf == current
else if passTexf == current
else // etc
Sure, that makes sense. How do I distinguish them? In your example, you use "emailTexf" and "passTexf", but where are you getting those from? Happy to upvote and select this as the answer, if you can help me clarify that. Thanks!
– RIP.Ben.Franklin
Mar 8 at 16:36
1
you need to replace them with your own variables , above is for an example
– Sh_Khan
Mar 8 at 16:37
Can you give a more complete example that explains what you're saying? Sorry, I'm not understanding. Thank you!
– RIP.Ben.Franklin
Mar 8 at 16:38
1
It's supposed you have outlets for the textfields to validate see edit
– Sh_Khan
Mar 8 at 16:40
Oh yeah! Of course! Got it! Thanks!
– RIP.Ben.Franklin
Mar 8 at 16:47
add a comment |
You don't have to as the paramter (_ textField: UITextField)
gives you the current textfield the user changes
Suppose you have
@IBOutlet weak var emailTexf:UITextField!
@IBOutlet weak var passTexf:UITextField!
func textFieldDidEndEditing(_ textField: UITextField)
self.validateAllFields(textField)
fun validateAllFields(_ current:UITextField)
if emailTexf == current
else if passTexf == current
else // etc
Sure, that makes sense. How do I distinguish them? In your example, you use "emailTexf" and "passTexf", but where are you getting those from? Happy to upvote and select this as the answer, if you can help me clarify that. Thanks!
– RIP.Ben.Franklin
Mar 8 at 16:36
1
you need to replace them with your own variables , above is for an example
– Sh_Khan
Mar 8 at 16:37
Can you give a more complete example that explains what you're saying? Sorry, I'm not understanding. Thank you!
– RIP.Ben.Franklin
Mar 8 at 16:38
1
It's supposed you have outlets for the textfields to validate see edit
– Sh_Khan
Mar 8 at 16:40
Oh yeah! Of course! Got it! Thanks!
– RIP.Ben.Franklin
Mar 8 at 16:47
add a comment |
You don't have to as the paramter (_ textField: UITextField)
gives you the current textfield the user changes
Suppose you have
@IBOutlet weak var emailTexf:UITextField!
@IBOutlet weak var passTexf:UITextField!
func textFieldDidEndEditing(_ textField: UITextField)
self.validateAllFields(textField)
fun validateAllFields(_ current:UITextField)
if emailTexf == current
else if passTexf == current
else // etc
You don't have to as the paramter (_ textField: UITextField)
gives you the current textfield the user changes
Suppose you have
@IBOutlet weak var emailTexf:UITextField!
@IBOutlet weak var passTexf:UITextField!
func textFieldDidEndEditing(_ textField: UITextField)
self.validateAllFields(textField)
fun validateAllFields(_ current:UITextField)
if emailTexf == current
else if passTexf == current
else // etc
edited Mar 8 at 16:39
answered Mar 7 at 21:25
Sh_KhanSh_Khan
46.6k51432
46.6k51432
Sure, that makes sense. How do I distinguish them? In your example, you use "emailTexf" and "passTexf", but where are you getting those from? Happy to upvote and select this as the answer, if you can help me clarify that. Thanks!
– RIP.Ben.Franklin
Mar 8 at 16:36
1
you need to replace them with your own variables , above is for an example
– Sh_Khan
Mar 8 at 16:37
Can you give a more complete example that explains what you're saying? Sorry, I'm not understanding. Thank you!
– RIP.Ben.Franklin
Mar 8 at 16:38
1
It's supposed you have outlets for the textfields to validate see edit
– Sh_Khan
Mar 8 at 16:40
Oh yeah! Of course! Got it! Thanks!
– RIP.Ben.Franklin
Mar 8 at 16:47
add a comment |
Sure, that makes sense. How do I distinguish them? In your example, you use "emailTexf" and "passTexf", but where are you getting those from? Happy to upvote and select this as the answer, if you can help me clarify that. Thanks!
– RIP.Ben.Franklin
Mar 8 at 16:36
1
you need to replace them with your own variables , above is for an example
– Sh_Khan
Mar 8 at 16:37
Can you give a more complete example that explains what you're saying? Sorry, I'm not understanding. Thank you!
– RIP.Ben.Franklin
Mar 8 at 16:38
1
It's supposed you have outlets for the textfields to validate see edit
– Sh_Khan
Mar 8 at 16:40
Oh yeah! Of course! Got it! Thanks!
– RIP.Ben.Franklin
Mar 8 at 16:47
Sure, that makes sense. How do I distinguish them? In your example, you use "emailTexf" and "passTexf", but where are you getting those from? Happy to upvote and select this as the answer, if you can help me clarify that. Thanks!
– RIP.Ben.Franklin
Mar 8 at 16:36
Sure, that makes sense. How do I distinguish them? In your example, you use "emailTexf" and "passTexf", but where are you getting those from? Happy to upvote and select this as the answer, if you can help me clarify that. Thanks!
– RIP.Ben.Franklin
Mar 8 at 16:36
1
1
you need to replace them with your own variables , above is for an example
– Sh_Khan
Mar 8 at 16:37
you need to replace them with your own variables , above is for an example
– Sh_Khan
Mar 8 at 16:37
Can you give a more complete example that explains what you're saying? Sorry, I'm not understanding. Thank you!
– RIP.Ben.Franklin
Mar 8 at 16:38
Can you give a more complete example that explains what you're saying? Sorry, I'm not understanding. Thank you!
– RIP.Ben.Franklin
Mar 8 at 16:38
1
1
It's supposed you have outlets for the textfields to validate see edit
– Sh_Khan
Mar 8 at 16:40
It's supposed you have outlets for the textfields to validate see edit
– Sh_Khan
Mar 8 at 16:40
Oh yeah! Of course! Got it! Thanks!
– RIP.Ben.Franklin
Mar 8 at 16:47
Oh yeah! Of course! Got it! Thanks!
– RIP.Ben.Franklin
Mar 8 at 16:47
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55052964%2fhow-can-i-override-a-swift-delegate-method-to-take-more-parameters%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You can't add more parameters. And there is no need. You are already told which text field is affected.
– rmaddy
Mar 7 at 21:23