objective c - Passing data through AppDelegate in ios -


In more than one occasion, I found useful to pass from one view to another: the form of a bridge using the controller AppDelegate: @MyAppDelegate: NSObject & lt; UIApplicationDelegate & gt; {CGFloat aFloatValue; }

In this way I can get "aFloatValue" from any controller:

  MyAppDelegate * appDelegate = (MyAppDelegate *) [[UIApplication sharedApplication ] Delegate];   

and

  app delegate.aFloatValue   

but I'm not sure that this is a good method. What do you think about it? I think it depends more on the data you are storing there and the context in which it relates.

For example, archiving application status, such as whether a user is logged in or not, seems perfectly acceptable. You may also have a group of apps that are related to the app that is not editable by the user, and is stored in a dictionary, and that word will be a good place to keep.

But, you say that you have Object A and Object B, which has a direct dependence on Object C, then you should go directly to Object C for that information, and not app Delayet.

Comments