title: How do you programmatically get the serial number of an iPhone?
body: <p>I want to know the serial number of my iPhone using my application.  I have writen code below.</p>
  
  <pre><code>- (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==&gt;%@",serialNumberAsCFString);
      NSLog(@"serail no==&gt;%@",serial);
  }
  </code></pre>
  
  <p>Why am I still getting wrong serial number?</p>