• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: API for fetching the computer name in cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: API for fetching the computer name in cocoa


  • Subject: Re: API for fetching the computer name in cocoa
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Fri, 12 Jun 2009 18:31:18 +0200


On 12 Jun 2009, at 15:21, Bill Monk wrote:


On Jun 12, 2009, at 5:43 AM, "Gerriet M. Denkmann" wrote:

		StringPtr c = (void *)response;
		NSUInteger cle = *c;
		char *cu = malloc( cle + 1);
		memcpy( cu, c + 1, cle);
		cu[cle] = '\0';
		NSLog(@"%s gestaltUserVisibleMachineName → \"%s\" (%lu chars)",


Can reduce to:

NSMutableString *cu = [NSMutableString string];
CFStringAppendPascalString( (CFMutableStringRef)cu, (StringPtr)response, kCFStringEncodingMacRoman );


NSLog( @"%s gestaltUserVisibleMachineName → \"%@\" (%u chars)", __FUNCTION__, cu, [cu length] );

Thanks a lot.
I had been looking for something like this, but after finding dozens of functions which all were marked as deprecated, I gave up.


Kind regards,

Gerriet.

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: API for fetching the computer name in cocoa (From: Bill Monk <email@hidden>)

  • Prev by Date: Re: Missing something about initialization
  • Next by Date: Re: problems with scripting
  • Previous by thread: Re: API for fetching the computer name in cocoa
  • Next by thread: Re: API for fetching the computer name in cocoa
  • Index(es):
    • Date
    • Thread