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

  • Home
  • SEARCH
  • 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 8732459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:26:41+00:00 2026-06-13T09:26:41+00:00

I have a Universal iOS app that loads certain pages into the UIWebView for

  • 0

I have a Universal iOS app that loads certain pages into the UIWebView for the user to see. Now there are a different set of pages for iPad and iPhone(each device type has its own directory of pages).

To redirect to the right page based on device type, my code in Xcode mentions the device type in the query string. I’m trying to do this through a macro:

#define BaseURL @"http://someurl/Pages/Login.aspx?"
#define QueryStringParam (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad) ? @"deviceType=iPad" : @"deviceType=iPhone"
#define LoginPageUrl    BaseURL QueryStringParam

The second macro here throws a compilation error “Called object type NSString* is not a function or function pointer”

So can I solve my problem at all using Macros? What’s the right syntax to use ternary operators in a Macro?

  • 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-13T09:26:42+00:00Added an answer on June 13, 2026 at 9:26 am

    The string concatenation with adjacent string literals only works when both are string literals, i.e.

    @"foo" @"bar"       is the same as         @"foobar"
    

    because @"foo" and @"bar" are string literals, but

    @"foo" (@"bar")     is compiler error
    

    because of the ( in between. This is the same situation as yours. In this case, you’d better concatenate the two strings in runtime:

    #define LoginPageUrl    [BaseURL stringByAppendingString:(QueryStringParam)]
    

    or force the compiler to see two adjacent string literals by combining the BaseURL and QueryStringParam

    #define LoginPageUrl \
        ((UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad) ? \
            BaseURL @"deviceType=iPad" : \
            BaseURL @"deviceType=iPhone")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a universal iOS app with a custom view that has three buttons,
I have a Universal iOS app that has been in the App Store for
I have written a universal iOS-App that runs fine on my iPhone and iPad,
Can I have certain settings that are universal for all my users?
My dilemma - I have a universal app that holds a lot of images
I working on a universal iOS app that gets news from an RSS feed.
I'm working on a universal app that uses the camera on iOS devices and
I'm in the process of creating a universal iOS app that, amongst other functions,
I have an iOS 4.2 universal app. I've tested the app against all available
I have built a universal iOS-app. The iPhone part is ready to go, the

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.