ios - Access View Controller's properties from AppDelegate -


I currently have a Xcode project in which I am using the storyboard in my app deliate, let me set some properties In response to the information received by AP, the other view controllers are contained in .h files.

How do I install an object of those view controllers to delete the app so that I can access and modify my properties?

App representatives have ways to get the right VC to handle and communicate with it, but better For the design, the flow of information is to be placed on the other side, the visual controllers ask for information and update their properties.

To do this, when the app representative receives any information, can it post related to NSNotification ( NSNotificationCenter ) . The visual controllers who care about the change can add themselves as a supervisor to this notification and get the information. How can they get it? In some ways:

There should be a model on the application for the textbook, perhaps a singleton in which there are relevant properties for visual controllers Idea two effectively assign their model to a model by giving this property a model It is for the VCS to make inquiries. Last idea, userInfo param: (NSString *) on postNotificationName: NotificationName Item: (ID) notificationSadder user information: (NSDictionary *) userInfo can convey information to the supervisor.

Edit - NSNotificationCenter is very easy to use. It happens in this way:

When you receive an external notification, in AppDelegate.m:

  // says that you have a view controller Background color of label text and its / / view NSDictionary * info = @ {@ "text": @ "hello", @ "color": [UIColor redColor]}; [[NSNotificationCenter defaultCenter] postNotificationName: @ "Hi ErieObbs" Object: Self-user information: info];   

In some ViewController.m, subscribe to the message:

  - (zero) viewDidoadload [[Super Viewedload]; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector (observed :) name: @ "hierbyby" object: zero]; } // When we leave, then unsubscribe - (zero) Delok {{[NSNetification sensor default center] to remove observer: self]; } // This method is triggered when the notification is posted / / in the user info property of the notification that data is included in the app delegate - (zero) is observed: (nsnotification *) notification { NSDragment * UserInfo = Notice Self.myLabel.text = userInfo [@ "text"]; Self.view.backgroundColor = userInfo [@ "Color"]; }    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -