Comment obtenez-vous par programme le numéro de série d'un iPhone?

Je veux savoir le numéro de série de mon iPhone à l'aide de mon application. J'ai écrit le code ci-dessous.

- (NSString*)getSerialNumber
{
 CFTypeRef serialNumberAsCFString;

 io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"));

 if (platformExpert)
 {
     serialNumberAsCFString = IORegistryEntryCreateCFProperty(platformExpert, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0);
 }

 IOObjectRelease(platformExpert);

 NSString *serial = [[NSString alloc] initWithFormat:@"%@",serialNumberAsCFString];

    NSLog(@"serail no==>%@",serialNumberAsCFString);
    NSLog(@"serail no==>%@",serial);
}

Pourquoi suis-je encore en train de faux numéro de série?

source d'informationauteur