Our app is targeting ios5.1 right now. And after installing MT 6.0.2 the deprecated warnings filled the build logs. Should the deprecated methods be still kept in the source or should they be replaced?
For instance, should I replace the following with:
public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
{
switch(toInterfaceOrientation) {
case UIInterfaceOrientation.LandscapeLeft:
case UIInterfaceOrientation.LandscapeRight:
return true;
default:
return false;
}
}
with
public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations ()
{
return UIInterfaceOrientationMask.Landscape;
}
or have both of the overridden methods in the code base?
There are several reasons for obsoleted methods. The message you get, from the compiler warnings, will tell you why a method was obsoleted. IOW iOS deprecated methods are a subset of them of obsolete methods.
When a new iOS version is released Apple often deprecated several API. This means that the API:
So those are warnings, not errors. You should review and decide how to deal with them. E.g.
If you're writing new code / app, that requires iOS6 as a minimum, then you should only be using new API (not deprecated ones);
If you're updating an application that requires you to be compatible with earlier iOS versions (e.g. 5.1) then you'll likely want to use the older API and, gradually, update them if it makes sense (e.g. iOS6 specific features, different code paths...).
If your application minimum supported iOS version is 4.2 you should not use API that were deprecated in 4.0, 3.2 ... but you should take care not to use newer API as well.
In your example the older
ShouldAutorotateToInterfaceOrientation
will work for both iOS5.1 and iOS6. So the easiest solution is to keep using this API as long as you want to support iOS 5.x.Overriding both means (in general) that iOS6 will call the newer one, while iOS5 will call the older one. This can makes testing difficult and it won't remove the obsoleted warnings when building your application. However if can make sense to do so (for some API) when you can get something better from the newer iOS API.