It looks like SCDynamicStoreCopyComputerName is not prototyped correctly so the 
compiler assumes it returns an int.  In what I assume is a 64-bit build this 
will lose the top 32 bits of the CFStringRef.

Are you #including <CoreServices/CoreServices.h>?  Other than that I am 
compiling 32 bit so I don't know what else might be wrong with the setup of 
your project but at least now you have an idea of what to look for.

Regards,

----------------------------------------------------------------------
Paul Sanders
AlpineSoft
http://www.alpinesoft.co.uk

----- Original Message ----- 
From: Steve Steinitz 
To: Paul Sanders ; cocoa-dev@lists.apple.com 
Sent: Sunday, June 20, 2010 11:52 AM
Subject: Re: Getting Computer Name


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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to