I am new to Objective-C, actually I want to display mac address when my device is connected to WiFi and I have seen many answers regarding this but I am unable to get what I want. So please can anyone guide me in form of tutorial. Thank you in advance.
Asked
Active
Viewed 9,427 times
2
-
6try This http://stackoverflow.com/questions/14827365/how-to-get-ios-device-mac-address-programmatically – Prashant Tukadiya Apr 04 '16 at 07:51
-
@PrashantTukadiya i have seen the link you provided but i have already gone through it but that code is not working – Balaji Praveen Apr 04 '16 at 08:29
1 Answers
5
Mac address is unavailable from ios 7 and up.
Apple Said
In iOS 7 and later, if you ask for the MAC address of an iOS device, the system returns the value 02:00:00:00:00:00. If you need to identify the device, use the identifierForVendor property of UIDevice instead. (Apps that need an identifier for their own advertising purposes should consider using the advertisingIdentifier property of ASIdentifierManager instead.)
Check bottom of the page into Apple Document.
So better solution for that. Following code returns unique address.
#import "UIDevice+Identifier.h"
- (NSString *) identifierForVendor1
{
if ([[UIDevice currentDevice] respondsToSelector:@selector(identifierForVendor)]) {
return [[[UIDevice currentDevice] identifierForVendor] UUIDString];
}
return @"";
}
Calling Method
NSString *like_UDID=[NSString stringWithFormat:@"%@",
[[UIDevice currentDevice] identifierForVendor1]];
NSLog(@"%@",like_UDID);
Also another solution visit HERE
Edited
UIDevice+Identifier.h
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface UIDevice (IdentifierAddition)
- (NSString *) identifierForVendor1;
@end
UIDevice+Identifier.m
#import "UIDevice+Identifier.h"
@implementation UIDevice (IdentifierAddition)
- (NSString *) identifierForVendor1
{
if ([[UIDevice currentDevice] respondsToSelector:@selector(identifierForVendor)]) {
return [[[UIDevice currentDevice] identifierForVendor] UUIDString];
}
return @"";
}
@end
Calling above Function.
ViewController.m
#import "ViewController.h"
#import "UIDevice+Identifier.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSString *like_UDID=[NSString stringWithFormat:@"%@",
[[UIDevice currentDevice] identifierForVendor1]];
NSLog(@"%@",like_UDID);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end

Nimit Parekh
- 16,776
- 8
- 50
- 72
-
-
-
-
[m:10:9: 'UIDevice+Identifier.h' file not found] showing me this error – Balaji Praveen Apr 04 '16 at 08:57
-
You just follow my above edited answer.It might be solve your problem. – Nimit Parekh Apr 04 '16 at 08:58
-