Say I have a property declared as : @property (nonatomic, strong) NSArray *menuArr;
OR @property (strong) NSArray *menuArr;
and set this property in viewDidLoad
. How long will the device "remember" the information I have stored in the array?
The property is declared and set in a viewController that is embedded in a navigationViewController that is itself the first view controller in a TabBarViewController. In other words its the first view the user sees then they may navigate away from it and back.
Without getting into a debate over atomic vs nonatomic my question is this
Does a property (declared either way) lives on infinitely in the iOS environment or is its lifespan limited by factors such as time, memory usage elsewhere, turning off the device, etc
To avoid this being an "x y problem" here's why Im asking:
Im working on an app that includes a menu broken up into multiple categories with several items in each category .....as you might expect a menu to be. All of the menu items are stored on parse.com. At first I was doing a separate PFQuery on each page, one on the categories page to get the categories, when user selects a category a new page is pushed and a second PFQuery got all the items in the chosen category. This worked but the pages took quite a while to load, probably 10-15 seconds sometimes with no real indication that the app hadnt just frozen up.
To fix this I decided to run one PFQuery when the first view of the app is loaded in viewDidLoad
getting all of the menu items and sorting the myself into nested arrays of categories containing items. I then store the menu array in a property on the viewController. Later, when I go to the menu I have the below in it's viewDidLoad
:
//get e reference to the first view controller, the one that has the menu array
FirstViewController *myVC1ref = (FirstViewController *)[[[self.navigationController.tabBarController.viewControllers objectAtIndex:0] viewControllers] objectAtIndex:0];
//set thisviewController's `menuArr` property to point to the menuArr on the first viewController.
_menuArr=myVC1ref.menuArr;
My understanding is that this creates a pointer to the original array and does not actually create a second array (please correct me if Im wrong).
This method takes about 10-15 seconds to load and sort the array that one time but then navigation between pages is instant after that which is much better.
I plan to do queries in places to see if any menu items have been changed and if so re-download and sort the menu.
So far in my testing the app seems to remember the info in the array just fine throughout the day with normal unrelated phone usage but there has to be some limits to that right?