Search code examples
iphoneios6ios7

How to resolve API deprecations in ios7?


What is the best way to resolve deprecations? I want my application to also work with older versions such as 6.0.

I have some code like this:

[leftButton setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor blueColor], UITextAttributeTextColor,nil] forState:UIControlStateNormal];

it is showing warning UITextAttributTextColor is deprecated. However things work just fine on ios7.

Now should I write version specific code (different code for 7.0 and prior versions?

I can easily resolve the warnings, but then I am afraid, it wouldn't work with prior versions. If I write separate blocks (as shown below), warning stays in the code. What is the best way to handle such situation?

Appreciate your help.


Solution

  • Just leave it there and change it when some future version actually removes the deprecations and marks it as error.