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













0















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!










share|improve this question






















  • 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















0















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!










share|improve this question






















  • 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













0












0








0








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!










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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

















  • 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












1 Answer
1






active

oldest

votes


















2














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






share|improve this answer

























  • 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











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
);



);













draft saved

draft discarded


















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









2














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






share|improve this answer

























  • 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















2














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






share|improve this answer

























  • 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













2












2








2







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






share|improve this answer















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







share|improve this answer














share|improve this answer



share|improve this answer








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

















  • 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



















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved