Challenge
In this challenge, you will write a Foundation Command Line Tool that prints out the name of your computer. This program will use two classes from the Foundation framework: NSHost and NSString.
First, you will get an instance of NSHost that has your computer’s information. Then you will ask the NSHost object for your computer’s name. Finally, you will use NSLog() to print out this name.
Here are more details that you will need:
-
To get an instance of NSHost, send the currentHost message to the NSHost class.
-
Once you have an instance of NSHost, send it the localizedName message. The localizedName method returns a pointer to an instance of NSString. Thus, you can store the result of sending this message in a variable ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access