gpt4 book ai didi

iphone - 如何在应用更新下载后再次调用 didFinishLaunchingWithOptions

转载 作者:行者123 更新时间:2023-11-28 18:04:25 25 4
gpt4 key购买 nike

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

我需要再次调用它 self.dataArray = [self readDataJsonFromDocument];当我从网上下载数据时再次调用它。

- (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];

}

最佳答案

你想做什么?

您当然可以手动第二次调用您的 App Delegate 的 didFinishLaunchingWithOptions 方法,但将所有功能放在一起可能更有意义你想在一个单独的函数中完成第二次,该函数由 both 附加到你的下载更新方法和 didFinishLaunchingWithOptions 方法的委托(delegate)调用。

关于iphone - 如何在应用更新下载后再次调用 didFinishLaunchingWithOptions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8569633/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com