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

  • Home
  • SEARCH
  • 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 252313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:40:04+00:00 2026-05-11T21:40:04+00:00

In the iphone app that I’m working on I use a custom class to

  • 0

In the iphone app that I’m working on I use a custom class to manage network communication with the host. The class called protocolClass is an ivar in the appDelegate and alloc + init in the applicationDidFinishLaunching: method.

Now whenever the protocolClass receive data from the host, it calls protocolClassDidReceiveData: method in its delegate (which I set as the appDelegate). I need then to update the data in one of the customViewControllers in the UINavigatorController.

Should I just add a reference to the customViewController I need to update in the appDelegate? or is there some other more efficient method?

If I were to keep a reference to the customViewcontroller, what are the memory usage ramifications?

Thanks in advance.

  • 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-11T21:40:04+00:00Added an answer on May 11, 2026 at 9:40 pm

    If I get you right, you want to update a view after an event occurs in some unrelated part of your program.

    To reduce the number of dependencies in your code, I’d recommend to use an NSNotification instead of the more tightly coupled instance variable. Notifications are a Cocoa concept, which allows one part of your code to emit an event-like message that any number of listeners can register for.

    In your case it would look like this:

    AppDelegate header:

    extern NSString* kDataReceived;
    

    AppDelegate implementation:

    NSString* kDataReceived = @"DataReceived";
    
    - (void)protocolClassDidReceiveData:(NSData*)data {
        [[NSNotificationCenter defaultCenter] postNotificationName:kDataReceived
                                                            object:self
                                                          userInfo:data];
    }
    

    in the implementation of some interested listener class (e.g. your UIViewController):

    // register for the notification somewhere
    - (id)init
    {
        self = [super init];
        if (self != nil) {
            [[NSNotificationCenter defaultCenter] addObserver:self
                                                     selector:@selector(dataReceivedNotification:)
                                                         name:kDataReceived
                                                       object:nil];
        }
    }
    
    // unregister
    - (void)dealloc
    {
        [[NSNotificationCenter defaultCenter] removeObserver:self];
    }
    
    // receive the notification
    - (void)dataReceivedNotification:(NSNotification*)notification
    {
        NSData* data = [notification userInfo];
        // do something with data
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an iPhone app that used to use an array of several thousand
WE are designing an iPhone app that will call back to a RESTful service
I am making an iPhone app that is designed for things that will be
I'm building an iPhone app that communicates with an external server via JSON. The
I am create an iPhone app that needs to talk to a Windows C#
I have an iPhone app that is showing a UIWebView which contains some fields.
I'm coding an iPhone app that needs to make small HTTP requests to the
I am developing an iPhone app that delivers alerts at certain times using UILocalNotifications
I'm writing an iPhone app that needs to download files that are sometimes over
I have an iphone app that when the user clicks a row in a

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.