防止多个用户同时在macOS上运行应用程序 [英] Prevent multiple users from running application simultaneously on macOS

查看:387
本文介绍了防止多个用户同时在macOS上运行应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

客户端应用程序使用共享的(核心数据)存储.该文件位于/Users/Shared/文件夹中,具有全局读写权限.

The client application uses a shared (Core Data) store. This is located in the /Users/Shared/ folder and has global read-write permissions.

我想防止其他用户登录(快速用户切换)并同时运行该应用程序和编辑同一商店.

I would like to prevent another user from logging in (fast user switching) and simultaneously running the application and editing the same store.

选中-[NSRunningApplication runningApplicationsWithBundleIdentifier:]仅列出在当前用户下运行的实例.

Checking -[NSRunningApplication runningApplicationsWithBundleIdentifier:] only lists instances running under the current user.

是否有一种简单的方法可以在所有用户中强制使用单个应用程序实例?

推荐答案

LSMultipleInstancesProhibited 添加到Info.plist文件.

Add LSMultipleInstancesProhibited to the Info.plist file.

<key>LSMultipleInstancesProhibited</key>
<true/>

请参见此答案 查看全文

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