Reputation: 1698
i have starting point on my application like this :
main.m :
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([LazyTableAppDelegate class]));
}
}
now in my LazyTableAppDelegate.m class :
i have function like this :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:TopPaidAppsFeed]
cachePolicy:0
timeoutInterval:160.0];
self.appListFeedConnection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];
NSAssert(self.appListFeedConnection != nil, @"Failure to create URL connection.");
// show in the status bar that network activity is starting
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
return YES;
}
In using storyboard to make TableView controller for my second xml fetch. after user clicks the row on first view second view will apear.
in second view im going to call this function to fetch another xml :
- (void)viewDidLoad
{
secondLazyTableAppDelegate *p = [[secondLazyTableAppDelegate alloc]init];
bool test = [p ??? ];
[super viewDidLoad];
self.imageDownloadsInProgress = [NSMutableDictionary dictionary];
}
is my method ok ? how can i call "didFinishLaunchingWithOptions" in second view ?
Upvotes: 0
Views: 118
Reputation: 2908
didFinishLaunchingWithOptions method is the starting point of your application
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
The function above is called once in it's life time which instantiates the application and contains all the data which you want to initialise once throughout the lifecycle of the application.
So if you want your app delegate to perform some function what you can do is create an another method say didFinishLaunchingCopy
- (void)didFinishLaunchingCopy
{
//Do what you want to perform
}
Inside your other view you can call the method like this
- (void)viewDidLoad
{
secondLazyTableAppDelegate *p = [[secondLazyTableAppDelegate alloc]init];
bool test = [p didFinishLaunchingCopy];
[super viewDidLoad];
self.imageDownloadsInProgress = [NSMutableDictionary dictionary];
}
This is a better and refine approach.
Upvotes: 1