0

I am trying to get the domain name of my macbook pro using following method.

NSString *name = [[NSHost currentHost] name];

It returns me the name like 'The-Special-MBP.local' but this is not consistent, It returns me some other string sometimes.

I am not getting why is this happening, the same function call returns two different values at different times.

Basically I need to indicate the different machines in network with some unique id or string hence I am reading the name from NSHost class but it gives different values for same machine.

Any help is appreciated.

karthika
  • 4,085
  • 3
  • 21
  • 23
subhash Amale
  • 325
  • 3
  • 4
  • 14

2 Answers2

0

It depends on your ethernet connection. Please you are connected in same network

Hussain Shabbir
  • 14,801
  • 5
  • 40
  • 56
0

If you want a unique id for your MAC, you may refer the following:

https://stackoverflow.com/a/5868967/1987246

Community
  • 1
  • 1
Neha
  • 1,751
  • 14
  • 36