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

The Archive Base Latest Questions

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

I have set up some constants in my Xcode project using the advice in

  • 0

I have set up some constants in my Xcode project using the advice in this question, and it works just fine. Now, however, I would like to set a different value for two of these constants depending on whether it’s an iPad or iPhone.

Here’s my Constants.h file:

extern integer_t const kFontSize;
extern integer_t const kFontSizeMicro;

and my .m:

integer_t const kFontSize = 16;
integer_t const kFontSizeMicro = 11;

Now I would like to change those values depending on a #define macro setup in my .pch file. But this doesn’t work:

if (IS_IPAD) {
    integer_t const kFontSize = 25;
    integer_t const kFontSizeMicro = 15;
}

The error I get is “Expected identifier or (” on the “if”.

Anyone know how to allow the conditional statement in this case?

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

    The if statement of the C language cannot be used outside a function body to control a global declaration like that. You can use the preprocessor’s #if instead:

    #if (IS_IPAD)
        integer_t const kFontSize = 25;
        integer_t const kFontSizeMicro = 15;
    #else
        integer_t const kFontSize = 20;
        integer_t const kFontSizeMicro = 12;
    #endif
    

    This is not too different from using #define-d constants, though. If you would like to make the constants settable at runtime, – say, during initialization, – you will need to drop const from the declarations, and put the regular if into an initialization function – for example, the application:didFinishLaunchingWithOptions:.

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

Sidebar

Related Questions

I have one AlertDialog which is working fine.I have set some background images to
I have some set of xml generated via xmlserialization of some WCF messages. Now
I'm using Google Test Framework to set some unit tests. I have got three
I have set some constants. public final double TWO = 50; public final double
In my init I have set some variables and one animate that uses those
I have to set some routing rules in my php application, and they should
I have set inside .bashrc some aliases that I need to be seen inside
I want to set some locations and have my app check if its by
I have java script code to set some of the properties of ajax controls.
I have a floated span with some text. I have set the overflow to

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.