• 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
Annotation to Hardware Address
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Annotation to Hardware Address


  • Subject: Annotation to Hardware Address
  • From: Max Seelemann <email@hidden>
  • Date: Sat, 9 Aug 2003 00:32:59 +0200

Hi there.

I just want to tell you my experience with this topic.
The problem was how to get the Hardware Address of the first (built-in) ethernet card.
There are two relatively easy way:

1)
- (NSString *)getEthernetAddress
{
NSString *str = @"";

OTInetGetInterfaceInfo(&myInetInterfaceInfo, 0);
if (myInetInterfaceInfo.fHWAddrLen > 0) {
for(i=0; i<myInetInterfaceInfo.fHWAddrLen; i++) {
str = [str stringByAppendingFormat: @"x", myInetInterfaceInfo.fHWAddr[i]];
}
}

return str;
}

2)
- (NSString *)getEthernetAddress
{
NSString *str, *uuid;

uuid = (NSString *) CFUUIDCreateString(0, CFUUIDCreate(0));
str = [[uuid componentsSeparatedByString: @"-"] lastObject];

return str;
}

Do not use the second way. Normally it gives the same as the first method,
but on some systems this can change when you (e.g.) switch between
AirPort and LAN. The first method is "safe" in this relation.

Thank you for your audience.

MAX
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: how to create an NSData from an NSString SOLVED
  • Next by Date: Re: duplicate preference keys
  • Previous by thread: how to create an NSData from an NSString SOLVED
  • Next by thread: compress/decompress - gzip and gunzip using cocoa
  • Index(es):
    • Date
    • Thread