- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的 Obj-C 应用程序中,我使用以下代码在 Pages(或任何其他应用程序)中打开文件:
[[NSWorkspace sharedWorkspace] openFile:theUrl withApplication:@"Pages"];
主要是当打开较大的文件时,这可能需要几秒钟才能完成。所以我希望我的应用程序等待页面,直到它完全打开文件。
以下代码是我想要的方式:
[[NSWorkspace sharedWorkspace] openFile:theUrl withApplication:@"Pages" onFinish:@selector(pagesfinishedopening)];
当然,我可以简单地使用 sleep() 函数,但这会减慢小文件上的应用程序的速度,并且当文件大于异常(exception)时将无法工作。
我已经尝试过使用 NSApplication 进行一些操作,但是页面中文件的打开不受尊重,只能监视目标应用程序的启动。
有什么想法吗?
最佳答案
您可以收听notifications从 NSWorkSpace 到达,如下所示
- (void)myMethod {
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
selector:@selector(appDidLaunch:)
name:NSWorkspaceDidLaunchApplicationNotification
object:nil];
[[NSWorkspace sharedWorkspace] openFile:theUrl withApplication:@"Pages"];
}
- (void)appDidLaunch:(NSNotification*)notification {
NSLog(@"app info: %@", [notification userInfo]);
}
关于cocoa - -[NSWorkspace openFile :withApplication:] wait for opening Application,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8897817/
我有一个应用程序,它是一个单窗口、非基于文档的应用程序。 我想让它响应 NSWorkspace-openFile:withApplication:,但仅当路径是文件夹时,并且还实现"file"->“打
像这样使用时 [ [NSWorkspace sharedWorkspace] openFile:fileName withApplication:appName]; 并且文件名包含空格 另一个应用程序
在我的 Obj-C 应用程序中,我使用以下代码在 Pages(或任何其他应用程序)中打开文件: [[NSWorkspace sharedWorkspace] openFile:theUrl withA
我正在使用 Specs2 和使用 Scala 2.10.2(运行 Java 1.7.0_51)构建的 play 2.2.1。我一直在阅读有关如何使用 Specs2 进行设置/拆卸的信息。我已经看到使用
https://groups.google.com/forum/#!topic/play-framework/76JjbcE2dYw 我正在看类似的问题。我正在使用 Play 2.0.3,但它仍然无法
我是网络应用程序开发的新手,对 Play Framework 更是如此。我的目标是确保我的应用程序经过良好测试,遵循测试驱动开发原则。 Play 在其文档中提供了多种测试 Play 应用程序的方法,而
我是一名优秀的程序员,十分优秀!