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

The iPhone app that I am working on requires GET calls to a 3rd
I have a iPhone app that I'm working on and it works alot like
Working on iPhone app that takes a photo and then uploads it to a
I have an iPhone app that must use external cloud db to sync data
I have an iPhone app that use UIPickerView and 3 buttons. This picker has
I have an iPhone app that used to use an array of several thousand
The iPhone app that I released is a wireless game controller, it translates touches
I have an iPhone app that hides the status bar. However, my main view
I have a simple iphone app that's based on the CrashLanding sample app. So
I'm developing an iPhone app that uses the built-in SQLite database. I'm trying to

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.