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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:32:11+00:00 2026-05-23T10:32:11+00:00

For test purposes I’ve created an application with UITabBar , 3 view controllers and

  • 0

For test purposes I’ve created an application with UITabBar, 3 view controllers and my class DataAnalyzer (till now it analyses nothing:)).

TestAppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
   //..... 
    NSArray *allControllers = [self.tabBarController viewControllers];

    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    for (UIVideoEditorController * viewController in allControllers) {
        [center addObserver:viewController selector:@selector(useUpdatedData:) name:@"dataUpdated" object:nil];
        NSLog(@"%@", [viewController description]);
    }    

    DataAnalizer *dataAnalizer = [[DataAnalizer alloc] init];
    [center addObserver:dataAnalizer selector:@selector(useUpdatedData:) name:@"dataUpdated" object:nil];
    // dataAnalizer can't be released here? Where should it be done?
    return YES;
}

in 2-nd, 3-rd view controllers and DataAnalyzer class I added the same method

- (void) useUpdatedData:(NSNotification *)note {
    NSLog(@"Notificatio received in *** view controller");

    //do something with [note object] like show it on a label or store it to instance variable
} 

in 1-st view controller I added text field to send a string as notification

- (void)textFieldDidEndEditing:(UITextField *)textField {

    NSLog(@"First viewController textFieldDidEndEditing: value is %@ ", textField.text);
    NSNotificationCenter *note = [NSNotificationCenter defaultCenter];
    [note postNotificationName:@"dataUpdated" object:textField.text];


}

When I send a string, I see NSLog message in console that notification is received, but can do nothing with the string like showing it on a label. I understand that it’s because a view controllers load first time and they were not initiated. But why I’m getting NSLog message in console? Can I send a string to dataAnalizer class, do something there and then get a result to second and third view controllers?
Thank you in advance for your answers, because it seems all above is a wrong approach.

  • 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-23T10:32:12+00:00Added an answer on May 23, 2026 at 10:32 am

    Apple documentation pretty clearly states that NSNotificationCenter does not retain it’s observers, thats why you can’t release the dataAnalyzer there – it would be dealloc’d and the notification would attempt to post to a nil reference.

    I don’t think it’s a good idea to loop through an array of controllers and subscribe each one to a notification. The controller isn’t guaranteed to be created at that point, and because it doesn’t know it’s been volunteered to answer a notification it also doesn’t know to unsubscribe. Instead, subscribe to the notification(s) in the -init method of each view controller. That ensures the controller has been created and initialized, and makes each controller responsible for it’s own actions.

    I’m not entirely sure what your question is, could you rephrase it if the above didn’t resolve your problem.

    Also, be aware NSNotificationCenter will post to all observers, but it is not async – it waits for each one to finish processing the notification before sending to the next object.

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

Sidebar

Related Questions

Consider a custom UIComponent (for test purposes only): public class UITest extends UIComponentBase {
I've created very simple web site for the test purposes. Only one master page
I've got some XML, for example purposes it looks like this: <root> <field1>test</field1> <f2>t2</f2>
Our test department has a series of web tests created using Visual Studio 2005
I have created a JavaScript application that requires all images to be preloaded first.
My question is simple. For unit test purposes, I need a statically compiled type
As the title says, should this technique be used only for test purposes or
For test purposes, I would like to insert a large amount of data (approx.
I just submitted my app for test purposes (seems like you need to submit/reject
I'm trying to set up an Apache server for test purposes. The goal is

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.