<span id="Label3"></p><p><p>Three common ways to get the model for your iOS device:</p></p><p><p>1. [uidevice Currentdevice].model (recommended);</p></p><p><p>2. uname (struct utsname *name), using this function requires # include;</p></p><p><p>3.sysctlbyname (const char *name, void *oldp, size_t *oldlenp, void *newp,</p></p><p><p>size_t newlen), using this function requires # include, #include;</p></p><p><p></p></p><p><p>The first approach is recommended for the top-level api, which is recommended for advanced APIs in project development because of its high recognition and ease of use. 2, 32 kinds are BSD level api, for the underlying api, not Recommended.</p></p><p><p></p></p><p><p>Example:</p></p><p><p>1. NSString * Strmodel = [uidevice currentdevice].model;</p></p><p><p></p></p><p><p>2. struct Utsname systemInfo</p></p><p><p>Uname (&systeminfo)</p></p><p><p>NSString * Strmodel = [nsstring stringWithCString:systemInfo.machine</p></p><p><p>encoding:nsutf8stringencoding];</p></p><p><p>3. size_t Size</p></p><p><p>Sysctlbyname ("hw.machine", null, &size, null, 0)</p></p><p><p>Char *model = (char *) malloc (size)</p></p><p><p>Sysctlbyname ("hw.machine", model, &size, NULL, 0)</p></p><p><p>NSString * Strmodel = [nsstring Stringwithcstring:model</p></p><p><p>encoding:nsutf8stringencoding];</p></p><p><p></p></p><p><p>After acquiring the device model, it is not possible to know exactly what type of device it is, but also to find the device description corresponding to its model number.</p></p><p><p>For example, ipad2,1 corresponds to IPad2 (WIFI).</p></p><p><p><span style="color: #ff6600;">This corresponding table has been well summed up by predecessors:</span></p></p><p><p></p></p><p><p><code class="objc keyword">struct</code><code class="objc plain">utsname systemInfo;</code></p></p><code class="objc plain"><code class="objc plain">uname(&systemInfo);</code></code><code class="objc keyword"><code class="objc keyword">NSString</code></code> <code class="objc plain"><code class="objc plain">*deviceString = [</code></code><code class="objc keyword"><code class="objc keyword">NSString</code></code><code class="objc plain"><code class="objc plain">stringWithCString:systemInfo.machine encoding:</code></code><code class="objc keyword"><code class="objc keyword">NSUTF8StringEncoding</code></code><code class="objc plain"><code class="objc plain">];</code></code><p><p>through, such as the above method can obtain the model information of the device, the specific correspondence is as follows, cut off 2013,2,5.</p></p><p>iphone 5,1 iphone5 (mobile, unicom)<br>iphone 5,2 iphone5 (mobile, telecom, unicom)<br>iphone 4,1 iphone4s<br>iphone 3,1 iphone4 (mobile, unicom)<br>iphone 3,2 iphone4 (unicom)<br>iphone 3,3 iphone4 (telecom)<br>iphone 2,1 iphone3gs<br>iphone iphone3g<br>iphone to iphone<br>ipad 1 ipad<br>ipad 2,1 ipad 2 (Wifi)<br>ipad 2,2 ipad 2 (GSM)<br>ipad 2,3 ipad 2 (CDMA)<br>ipad 2,4 ipad 2 (32nm)<br>ipad 2,5 ipad Mini (Wifi)<br>ipad 2,6 ipad Mini (GSM)<br>ipad 2,7 ipad Mini (CDMA)<br>ipad 3,1 ipad 3 (Wifi)<br>ipad 3,2 ipad 3 (CDMA)<br>ipad 3,3 ipad 3 (4G)<br>ipad 3,4 ipad 4 (Wifi)<br>ipad 3,5 ipad 4 (4G)<br>ipad 3,6 ipad 4 (CDMA)<br>ipod 5,1 ipod Touch 5<br>ipod 4,1 ipod touch 4<br>ipod 3,1 ipod Touch 3<br>ipod 2,1 ipod Touch 2<br>ipod + ipod Touch</p><p><p></p></p><p><p>Summary of how to get the iOS device model</p></p></span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service