• 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: Getting Computer Name
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting Computer Name


  • Subject: Re: Getting Computer Name
  • From: Steve Steinitz <email@hidden>
  • Date: Sun, 20 Jun 2010 20:52:06 +1000

Hi Paul,

Thanks for your reply.

On 20/6/10, Paul Sanders wrote:

I use #1 and it works fine for me.  Note that
SCDynamicStoreCopyComputerName might return NULL, and don't forget to
CFRelease temp.

OK, thanks.

In the case of #1, what is the NSLog statement that is failing?  And I
take it that name hasn't been autoreleased before you log it - it will
only survive until the current autorelease pool 'pops'.

Good points and questions. Here is my method:

+ (NSString *)
computerName
{
    CFStringRef   temp = SCDynamicStoreCopyComputerName (NULL, NULL);
    NSString    * name = [NSString stringWithString: temp];
    NSLog (@"computer name = %@", name);
    CFRelease (temp);
    return name;
}

The line creating temp warns: initialization makes pointer from integer.

The line creating name warns: passing argument 1 of StringwithString from incompatible pointer type
and fails with signal EXC_BAD_ACCESS


Thanks again,

Steve

_______________________________________________

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


  • Follow-Ups:
    • Re: Getting Computer Name
      • From: "Paul Sanders" <email@hidden>
References: 
 >Re: Getting Computer Name (From: "Paul Sanders" <email@hidden>)

  • Prev by Date: Re: Getting Computer Name
  • Next by Date: Re: Getting Computer Name
  • Previous by thread: Re: Getting Computer Name
  • Next by thread: Re: Getting Computer Name
  • Index(es):
    • Date
    • Thread