-1

Is there a way to get systemName (e.g. 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"
Vibhor Goyal
  • 2,405
  • 2
  • 22
  • 35
  • http://stackoverflow.com/a/24004701/2594699 – Nhat Dinh Feb 03 '17 at 03:40
  • Possible duplicate of [How do I determine the OS version at runtime in OS X or iOS (without using Gestalt)?](http://stackoverflow.com/questions/11072804/how-do-i-determine-the-os-version-at-runtime-in-os-x-or-ios-without-using-gesta) – Nhat Dinh Feb 03 '17 at 03:40
  • How many different operating systems do you expect? – vadian Feb 03 '17 at 20:42

1 Answers1

0

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]
James Chen
  • 10,794
  • 1
  • 41
  • 38
  • Sorry I pasted the incorrect command in my question above earlier. I have modified it to the correct one. I am looking for system name, not version. – Vibhor Goyal Feb 03 '17 at 20:34
  • Updated the answer but also wondering if you already know it's AppKit, which system names are you expecting? – James Chen Feb 04 '17 at 02:47
  • I am expecting "macOS" in case of Sierra and "Mac OS X" in case of previous versions. Very similar to what systemName does on iOS. – Vibhor Goyal Feb 05 '17 at 20:21
  • In that case I'd say it's probably more easier to just get version number and do a simple mapping. – James Chen Feb 07 '17 at 01:11
  • I do understand that creating a mapping is a possible solution, I was just trying to see if there is an existing method. – Vibhor Goyal Feb 07 '17 at 01:29