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 194347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:35:15+00:00 2026-05-11T16:35:15+00:00

Consider the following common situation: You have some MainView in your Cocoa application, loaded

  • 0

Consider the following common situation:

You have some MainView in your Cocoa application, loaded from a NIB, which is controlled by a MainViewController. Your MainView contains some controls, such as a UILabel infoLabel. You also have a delegate MyDelegate class which receives some sort of event.

You would like to make sure that when MyDelegate receives its event, the infoLabel is updated appropriately. However, the problem is that MyDelegate does not have a reference to the MainView or the MainViewController and does not know about the label.

One solution is to pass a MainViewController reference to the delegate object, but this feels wrong because you might find yourself in the undesirable situation where the object has each other’s references.

What is the proper design to solve this problem?

  • 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-11T16:35:15+00:00Added an answer on May 11, 2026 at 4:35 pm

    In an unnamed developer forum, someone writes:

    So, to make a long story short, I have decided that I will start making use of NSNotifications. The Stanford course online that people have been following is taught by two Apple engineers. They have just now unequivocally said NOT to use the app delegate or global variables, and have said to use NSNotifications, delegates, and K-V observing.

    If that is what the Apple engineers say, I am going to move in that direction.

    The NSNotifications are pretty ingenious in that they don’t really interfere with encapsulation that much. The listener only listens for the notification and an object – I don’t think it has to know or care who sent it.

    So in your example I would consider having the delegate post a notification that the label had changed, or better yet have the controller observe that property if possible.

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

Sidebar

Related Questions

Consider following assumptions: I have Java 5.0 Web Application for which I'm considering to
I have some queries with following scenario on github. consider there is one organization
Consider following scenario: I have RESTful URL /articles that returns list of articles user
Let's consider following, simplified example: We have 2 tabs withing <rich:tabPanel switchType=ajax> , each
consider the following pgSQL statement: SELECT DISTINCT some_field FROM some_table WHERE some_field LIKE 'text%'
Using static class members in a class is a common practice. consider the following
Having the SOLID principles and testability in mind, consider the following case: You have
I have the following problem. Consider the classes class face { virtual std::vector<ptr>& get_vertices(void)
I am using DBContext API from EF 4.1. Consider following entity model (A, B,
Everyone, I'm using MVC 3 (Razor). I have the following problem: I have some

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.