可可App开机启动画面 [英] Cocoa App booting splash screen

查看:87
本文介绍了可可App开机启动画面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Mac应用程序连接到远程数据库,连接和提取数据大约需要10秒钟.由于框架初始化和网络延迟等原因,无法缩短此时间.

My Mac app connects to a remote db which takes about 10 seconds to connect and pull data. This time cannot be shortened due to framework initialisation and network latency etc.

我希望从应用程序的初始启动时间到应用程序准备就绪并完成时的启动画面.

I want put a splash screen from the initial app launch time to when the app is ready and done it’s thing.

我尝试了applicationWillFinishLaunching:(NSNotification *)notification方法,但是直到应用程序启动它才显示启动屏幕,这很有意义,因为AppDelegate似乎是最后创建的对象,并且App控制器在整个操作之前就已经完全初始化了应用将完成启动",这是延迟所在.

I have tried applicationWillFinishLaunching:(NSNotification *)notification method but it does not display the splash screen until the app is up, which makes sense, as the AppDelegate seem to be the last object created and the App controller gets init’d completely before the whole app "will finishing launching" which is where the delay is.

停靠图块开始弹跳后,有什么方法可以调用此窗口吗?

Is there any way to invoke this window as soon as the dock tile starts bouncing?

我知道我会因为优化而被拒绝,但是无法采取进一步措施来加快这一过程.

I know I will get shot down for optimising, but no further steps can be taken to speed this process up.

推荐答案

也许您可以使用GCD异步地将耗时的任务分派到后台线程,以便应用程序委托可以继续:

maybe you could dispatch your time consuming task to a background thread asynchronously with GCD so that the app delegate can move on:

 dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);

    dispatch_async(queue, ^{
        // time consuming task
    });

更新:

如果涉及UI的更改,则可以调用dispatch_get_main_queue()在主线程(而不是后台线程)上执行繁重的任务.

you can call dispatch_get_main_queue() to do your onerous tasks on the main thread as opposed to the background thread if they involve changes to the UI.

这篇关于可可App开机启动画面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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