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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:25:35+00:00 2026-05-25T11:25:35+00:00

There are 2 main considerations to take into account when thinking about backward compatibility

  • 0

There are 2 main considerations to take into account when thinking about backward compatibility :

  • build target
  • current SDK for compilation

If I compile with iOS SDK 3.1.3, [UIScreen mainScreen].scale will raise an error.

To deal with this, I can write :

CGLoat scale = 1.0;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
scale = [UIScreen mainScreen].scale;
#endif 

But… if my minimum version target is let’s say 3.1.3, this call will crash a 3.1.3 device, even if it compiles fine.

So I must write :

CGFloat scale = 1.0;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
    if ([UIScreen instancesRespondToSelector:@selector(scale)])
        scale = [UIScreen mainScreen].scale;
#endif

Saying that, I wonder if there is a way to implement

- (CGFloat)scale;

into a UIScreen category, inside which I could manage this kind of problem, and then the caller would just have to write :

CGFloat scale = [UIScreen mainScreen].scale;

without having to think about its used SDK nor its min target.

If possible, how would you write such a category so that it compiles fine with a 3.1.3 SDK, a 4.3 SDK, and runs fine on a 3.1.3 device as on a 4.3 device?

  • 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-05-25T11:25:36+00:00Added an answer on May 25, 2026 at 11:25 am

    You could do this with some method-swizzling, but I really wouldn’t recommend it (gets confusing really fast).

    I’d prefix your category method instead, something like foo_scale. This way you won’t run into name conflicts and you still only have one method to call.

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

Sidebar

Related Questions

I see there are two main options for managing transactions with llblgen. Method 1:
In this picture,there are 3 main steps: SetExpressCheckout , GetExpressCheckoutDetails and DoExpressCheckoutDetails ,I'm now
I have a VB6 app. There is a main form. It houses a user
I have a wx.Frame, in which there is a main wx.Panel with several widgets
I've got the following nonstandard setup (VS2008, .NET 3.5 SP1): There is a main
Scenario I have a Windows Forms Application. Inside the main form there is a
I have a scenario. (Windows Forms, C#, .NET) There is a main form which
There is any ways to listing all main directories present in php server(may it
Is there any way for the main form to be able to intercept events
Is there a way to know the main/calling request in an httpmodule? I only

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.