Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 318505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:34:32+00:00 2026-05-12T08:34:32+00:00

In many situations, such as making the keyboard go away when the use clicks

  • 0

In many situations, such as making the keyboard go away when the use clicks done, there are two options: set the text field’s delegate to self, and adopt the UITextFieldDelegate protocol, and then use the method

- (BOOL)textFieldShouldReturn:(UITextField *)textField; 

to resignFirstResponder and return YES. But you can also

      addTarget:self 
         action:@selector(myMethod:) 
forControlEvent:UIControlEventDidEndOnExit]; 

or something like that, using the did end on exit event, and then in the method, [sender resignFirstResponder]. So what is the best option in situations like these: the delegate, or the event?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T08:34:32+00:00Added an answer on May 12, 2026 at 8:34 am

    If you are going to be paired with one other class, where the real type of that class may vary, then it makes a lot of sense to formalize that pairing into a protocol and a delegate arrangement.

    If the information you want to send is targeted at a broader set of objects, then it starts to make more sense to use notifications – though now you have somewhat obscured what information is being passed by the notification as there’s no central definition for what to expect.

    Both are about an equal load to work with – with a delegate you have to set yourself and then remember to unset yourself before you are deallocated. You have to do the same thing with notifications, remember to start listening and then unsubscribe before you are deallocated.

    Also, you should try as much as possible to make sure you send notifications out on the main thread as the notices get sent on the same thread they started from. Same goes for delegate methods, it’s not very kind to call a delegate method from some other mystery thread!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I bet many of you were in such situations in the past. I'm currently
Possible Duplicate: Properties vs Methods For many situations it is obvious whether something should
I'm writing an app, and in many situations need to have direct access to
I have been in both situations: Creating too many custom Exceptions Using too many
Many of us need to deal with user input, search queries, and situations where
I have a one-to-many relationship between two classes for this situation. I have a
From the Django documentation... When you're only dealing with simple many-to-many relationships such as
AFAIK, there are two ways of passing data to the view from controller :
Many times when I've written stored procedures, etc. I use a CURSOR at first
I've seen many situations before where a PK is a Guid with no default

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.