How can I access data that's stored in my App Delegate from my various view controllers?
Posted
by BeachRunnerJoe
on Stack Overflow
See other posts from Stack Overflow
or by BeachRunnerJoe
Published on 2010-06-06T02:28:26Z
Indexed on
2010/06/06
2:32 UTC
Read the original article
Hit count: 360
This question is similar to this other post, but I'm new to iPhone development and I'm getting used to the good practices for organizing my data throughout my app. I understand the ApplicationDelegate object to be the best place to manage data that is global to my app, correct? If so, how can I access data that's stored in my App Delegate from various view controllers? Specifically, I have an array of table section titles for my root table view controller created as such...
appdelegate.m
sectionTitles = [[NSArray alloc] initWithObjects: @"Title1", @"Title2", @"Title3", nil];
rootViewController.appDelegate = self;
and I need to access it throughout the different views of my app, like such...
rootviewcontroller.m
NSUInteger numSections = [self.appDelegate.sectionTitles count];
Is this the best way to do it or are there any reasons I should organize my data a better way?
Thanks so much in advance for your help!
© Stack Overflow or respective owner