Just wondering, on the Challenge, should we be able to print out the localized name using an instance of NSString created with the stringWithFormat: method? I guess basically I’m just wondering how you print an instance of NSString created with the stringWithFormat: method? Does NSLog work with this, or would you only use that to count the characters in the string or check if two strings were equal, etc?
Here is what I have (thanks to one of the posters on the Challenge thread for getting me started with his code, which clarified my thoughts on how to accomplish the initial task)
//create a NSHost object for this Mac
NSHost *thisComputer = [[NSHost alloc] init];
//Get the name of this Mac NSString *thisComputerName = [thisComputer localizedName]; //Print this Mac's name NSLog(@"This computer's localized name is %@.", thisComputerName);[/code]
Everything works fine up to here. It prints the name like it should. I was just wondering if, given the text, we should also be able to print using the stringWithFormat method.
[code] //use NSString stringWithFormat to print this Mac’s name
NSString *longWayName = [NSString stringWithFormat:@"This computer's name is %@.", thisComputerName]; NSLog(@"longWayName.");[/code] Of course, all this does is print out "longWayName". Am I trying to do something impossible, or just missing something? I suspect the latter. :slight_smile: