简体   繁体   中英

iOS: How to get access to a variable used in the root view controller when I'm 2 levels down in the navigation stack?

I'm trying to build an app that sends and HTTP request and some part of this request is stored in an object in the root view controller. How can I get access to this object once I'm two levels down in the navigation stack? Global variables declared in the App Delegate? I'm trying to keep MVC rules in place.

Storing such information in View Controllers isn't a good idea, imo. Better, create a class that manages your HTTP request and call to it from anywhere you want (singleton, or just pass an instance)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM