gpt4 book ai didi

objective-c - 当模拟器从 XCode 关闭时,是否有运行的方法?

转载 作者:行者123 更新时间:2023-12-05 08:00:40 25 4
gpt4 key购买 nike

这纯粹是为了开发目的,因为在设备上你可以使用

-(void)applicationDidEnterBackground:(UIApplication *)application

但我经常只是点击 XCode 中的停止按钮来停止模拟器运行,我需要某种方法来运行,所以它可以告诉数据库当前玩家已经停止播放,知道该怎么做吗?

最佳答案

我认为这个 Apple 问答会很有趣:Detecting the Debugger

我在 this article 的中途找到了它:

Apple provided a little function to determine whether the debugger is attached here. So as soon as my application starts in the Simulator, I'll let it wait:

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

{

#if DEBUG

// Wait max. 10 secs for debugger to attach again:

double waitTime = 0.0;
while (AmIBeingDebugged() == NO && waitTime < 15.0)
{
[NSThread sleepForTimeInterval:0.25];
waitTime += 0.25;
}

#endif

关于objective-c - 当模拟器从 XCode 关闭时,是否有运行的方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17642703/

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