gpt4 book ai didi

objective-c - 在 obj-c 中关闭 sqlite3 连接的最佳位置是什么?

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

我在 AppDelegate.m 中打开数据库连接

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

我正在关闭 applicationWillTerminate

- (void)applicationWillTerminate:(UIApplication *)application
{
/*
Called when the application is about to terminate.
Save data if appropriate.
See also applicationDidEnterBackground:.
*/
NSLog(@"Closing DB");
if(database) sqlite3_close(database);
}

但是当我在模拟器上关闭(真正关闭)应用程序时,我没有在控制台中看到日志“Closing DB”。正常吗?

在 Objective-c 中关闭 sqlite3 连接的最佳位置是什么?

(真正接近的意思是

– 双击主屏幕按钮调出多任务栏– 按住多任务栏上的任意位置,直到上面的图标开始摆动。– 当它们摆动时,每个图标上方都有一个减号符号。– 按任何应用程序上方的减号将其关闭。)

最佳答案

这是因为您的应用程序没有终止。它进入背景。尝试将您的代码添加到 applicationDidEnterBackground

关于objective-c - 在 obj-c 中关闭 sqlite3 连接的最佳位置是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8487977/

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