在应用程序更新下载后如何再次调用didFinishLaunchingWithOptions [英] how to call didFinishLaunchingWithOptions again after in app updates download

查看:37
本文介绍了在应用程序更新下载后如何再次调用didFinishLaunchingWithOptions的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在应用更新下载后如何再次调用didFinishLaunchingWithOptions,因为我所有的函数调用都在其中.

i will like to know how do i call didFinishLaunchingWithOptions again after in app updates download, as all my function calling are in there.

我需要再次调用 self.dataArray = [self readDataJsonFromDocument]; ,因为我是从网上下载数据的.

i need to call this again self.dataArray = [self readDataJsonFromDocument];again as i download data from the net.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{   


    [self   UIAppearances];    

    //first load
    [self copyJsonFromBundle];

    [self copyFolderFromBundle];

    self.dataArray = [self readDataJsonFromDocument]; //i need to call this again

    // Override point for customization after application launch.
    // Add the tab bar controller's current view as a subview of the window


    self.window.rootViewController = self.tabBarController;
    [self.window makeKeyAndVisible];

    return YES;
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {



    //NSString *downloadFolder = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"download"];

    //save to a temp file
    NSString* filePath = [NSString stringWithFormat:@"%@/temp.zip", self.documentsDir];

    //download folder
    //NSString* downloadFolder = [NSString stringWithFormat:@"%@/download", self.documentsDir];

    [self.fileManager createFileAtPath:filePath contents:self.receivedData attributes:nil];

    ZipArchive *zipArchive = [[ZipArchive alloc] init];

    if([zipArchive UnzipOpenFile:filePath]) {

//      if ([zipArchive UnzipFileTo:downloadFolder overWrite:YES]) {
        if ([zipArchive UnzipFileTo:self.documentsDir overWrite:YES]) {

            //unzipped successfully
            NSLog(@"Archive unzip Success");
            [self.fileManager removeItemAtPath:filePath error:NULL];
            [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
        } else {
            NSLog(@"Failure To Unzip Archive");             
            [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
        }

    } else  {
        NSLog(@"Failure To Open Archive");
    }


    //[self performSelectorOnMainThread:@selector(didUpdate) withObject:nil waitUntilDone:YES];

    //Update Document File
    NSString *updateUTCPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"UTCDate"];
    NSDate *currentDate = [NSDate date];
    NSArray *array = [NSArray arrayWithObject:currentDate];
    [array writeToFile:updateUTCPath atomically:YES];

}

推荐答案

您要做什么?

您当然可以 手动 再次调用您的应用程序委托的 didFinishLaunchingWithOptions 方法,但是放置所有功能可能更有意义您想第二次进入一个单独的函数,该函数由附加到您的下载更新方法和 didFinishLaunchingWithOptions 方法的两者调用.

You can certainly manually call your App Delegate's didFinishLaunchingWithOptions method a second time, but it would probably make more sense to put all the functionality you want to be done a second time into a separate function that gets called by both the delegate that's attached to your download updates method and the didFinishLaunchingWithOptions method.

这篇关于在应用程序更新下载后如何再次调用didFinishLaunchingWithOptions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆