I'd like to find how to extract my computer name programmatically, similar to the output of following terminal command scutil --get ComputerName
. This value can also be found under "About this mac" -> "System Software Overview" as shown in the following image :
So I've found one way is to use NSHost, but it's long been deprecated:
[[NSHost currentHost] localizedName]
In NSHost.h it mentioned where to look for ..
Use Network framework instead, see deprecation notice in <Foundation/NSHost.h>
So I've looked there and found nw_endpoint_get_hostname
but it has no proper documentation for how to be used to fetch local hostname.
Any Idea how to fetch this data programmatically (swift/objective-c/c++)