Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8823317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:19:26+00:00 2026-06-14T06:19:26+00:00

Detecting different hardware at runtime is useful for analytics (among other, even more questionable

  • 0

Detecting different hardware at runtime is useful for analytics (among other, even more questionable purposes).

Many iOS app creators may be interested to know how many users are experiencing their app on an iPad mini (rather than just knowing how many users are experiencing their app on an iPad with 1024×768 screen resolution – which would also be interesting).

Is there any public API in Cocoa touch/UIKit/ObjC/C which could be used to detect that your iOS app is running on an iPad mini at runtime? Ideally, this method should distinguish between iPad 2 & iPad mini (which have the same number of pixels, but a different pixel density).


Post Script: I realize many people will consider detecting iPad mini at runtime a bad idea. However, I think this is a valid question with a definite Yes or No answer. An answer which I think it is useful for the community to know.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:19:28+00:00Added an answer on June 14, 2026 at 6:19 am

    Boxel’s answer would be good if it didn’t invoke undefined behavior and if it didn’t have superfluous parts. One, + [NSString stringWithCString:encoding:] requires a C string – that is, a NUL-terminated char pointer (else it will most likely dump core). Also, you don’t need the conversion to NSString – since sysctlbyname() provides you with a plain old C string (without the NUL terminator, of course), you can directly use strcmp() to save a few dozen CPU cycles:

    #include <sys/sysctl.h>
    
    size_t size;
    sysctlbyname("hw.machine", NULL, &size, NULL, 0);
    char *machine = malloc(size + 1);
    sysctlbyname("hw.machine", machine, &size, NULL, 0);
    machine[size] = 0;
    
    if (strcmp(machine, "iPad2,5") == 0) {
        /* iPad mini */
    }
    
    free(machine);
    

    Edit: now that answer is fixed as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: iOS - Detecting whether or not device support phone calls? I'm writing
I read different responses to the question of detecting stack growth detection and I
Been trying some different ways of detecting if a remote Socket has disconnected. I
I have been looking at different methods of detecting the pitch of a tone
I found many ways to detect different shapes. But hard luck when I am
Im using pan gesture for showing different images. Pan gesuture is detecting correctly. The
How could I go about detecting (returning true/false) whether an ArrayList contains more than
I've gone through many different questions and for some reason, I still cannot get
If I have two models that are very different, is it defeating the purpose
I'm now detecting all the skeleton in a wpf application, I want to know

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.