title: Detect the specific iPhone/iPod touch model
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/448162/determine-device-iphone-ipod-touch-with-ios">Determine device (iPhone, iPod Touch) with iOS</a>  </p>
  </blockquote>
  
  
  
  <p>I am making a game that utilizes the peer-to-peer bluetooth capabilities of the iPhone (and probably the iPod touch 2nd generation). However, to stop the users from trying to play a multiplayer on an iPod 1st gen and iPhone 2G I need to check for the specific device model.</p>
  
  <p>[[UIDevice currentDevice] model] will only tell me if the device is an "iPhone" or an "iPod touch". Is there a way to check for the specific device model, like: "iPhone 3GS", "iPod touch 1st generation" or something.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>There is a category to UIDevice (I think it's created by Erica Sadun, I don't take credit for it) that uses the following code to get the specific device model. You can find the whole category here along with other useful stuff: <a href="https://github.com/erica/uidevice-extension" rel="nofollow noreferrer">https://github.com/erica/uidevice-extension</a></p>
  
  <pre><code>#include &lt;sys/types.h&gt;
  #include &lt;sys/sysctl.h&gt;
  
  @implementation UIDevice (Hardware)
  
  /*
   Platforms
   iPhone1,1 -&gt; iPhone 1G
   iPhone1,2 -&gt; iPhone 3G 
   iPod1,1   -&gt; iPod touch 1G 
   iPod2,1   -&gt; iPod touch 2G 
  */
  
  - (NSString *) platform
  {
    size_t size;
    sysctlbyname("hw.machine", NULL, &amp;size, NULL, 0);
    char *machine = malloc(size);
      sysctlbyname("hw.machine", machine, &amp;size, NULL, 0);
      NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];
    free(machine);
    return platform;
  }
  </code></pre>
  
  <p>This works and apps using this have been lately approved in the AppStore.</p>