简体   繁体   中英

systemVersion equivalent for AppKit

Is there a way to get systemName (eg macOS or Mac OS X) in AppKit?

Essentially, I am looking for a AppKit equivalent of the following UIKit command:

[[UIDevice currentDevice] systemName]

EDIT: Please note that I am not looking for OS version, I am looking for name of the OS. For example on systemName on iOS returns "ios"

@property(nonatomic,readonly,strong) NSString    *systemName;        // e.g. @"iOS"

You are looking for NSProcessInfo .

For example, one of the handy method is (which is localized):

[[NSProcessInfo processInfo] operatingSystemVersionString]

And another one which always returns NSMACHOperatingSystem on macOS but is already deprecated:

[[NSProcessInfo processInfo] operatingSystemName]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM