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 8660385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:14:27+00:00 2026-06-12T16:14:27+00:00

I am writing some code with dispatch_async and get different results on an iphone

  • 0

I am writing some code with dispatch_async and get different results on an iphone 4s and ipad 1st gen.

I am wondering if it is due to the number of cores the CPU has. Is it possible to detect the number of cores or CPU type of an iOS device at runtime so I can dispatch_async on the 4s, but not on the ipad?

  • 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-12T16:14:28+00:00Added an answer on June 12, 2026 at 4:14 pm

    Here’s the code to detect the number of cores on an iOS device:

    #include <sys/sysctl.h>
    
    unsigned int countCores()
    {
        size_t len;
        unsigned int ncpu;
    
        len = sizeof(ncpu);
        sysctlbyname ("hw.ncpu",&ncpu,&len,NULL,0);
    
        return ncpu;
    }
    

    In addition to that, you can check against the [[UIDevice currentDevice] userInterfaceIdiom] to determine if the device is an iPhone or an iPad. Like this:

    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
        NSLog(@"iPad");
    }
    else {
        NSLog(@"iPhone");
    }
    

    Reference

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

Sidebar

Related Questions

I am re-writing some code for a new re-design and I am wondering if
I am writing some code where I count the number of Div children and
I'm writing some code that needs to process an arbitrary number of lists of
I need help with writing some code that will create a random number from
I'm writing some code that plays back WAV files at different speeds, so that
I am writing some code that has a very large number of reasonably simple
I'm writing some code that increments the number at the end of a filename
I'm writing some code to calculate the number of 1s appeared in the 2's
So I'm writing some code and using RegistryKey.GetValue and I can't seem to get
I'm writing some code that will take a screenshot of another application, given its'

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.