How to Get OSX version during boot time in a daemon programme

144 views Asked by At

As Gestalt is deprecated in 10.10, so I use Apple Script to determine OSX version, the implementation is as follows:

NSAppleScript *script = [[NSAppleScript alloc] initWithSource:@"set os_version to do shell script \"sw_vers -productVersion\""];

but this apple script fails during boot time and daemon gets crash. I can't use NSProcessInfo operatingSystemVersion as I am using OSX SDK 10.8 and for now I don't want to upgrade my code to Xcode 6. I can't use operatingSystemVersionString also because as per Apple Docs - it is not safe for parsing.

Could anyone please tell me how to get OSX version on 10.10 during boot time using OSX SDK 10.8.

Could we achieve it through NSTask?

1

There are 1 answers

0
Anoop Vaidya On

The documentation says :

NewGestalt()    DEPRECATED 

Deprecated: Use NewGestaltValue instead wherever possible.

Summary: Adds a selector code to those already recognized by Gestalt.

Discussion: The NewGestalt function registers a specified selector code with the Gestalt Manager so that when the Gestalt function is called with that selector code, the specified selector function is executed. Before calling NewGestalt, you must define a selector function callback. See SelectorFunctionProcPtr for a description of how to define your selector function.

Registering with the Gestalt Manager is a way for software such as system extensions to make their presence known to potential users of their services.

In Mac OS X, the selector and replacement value are on a per-context basis. That means they are available only to the application or other code that installs them. You cannot use this function to make information available to another process.

A Gestalt selector registered with NewGestalt() can not be deleted.