How to Deprecate your Own API in Objective-C

To mark some of your own API as deprecated in Objective-C, you simply can add the following attribute to your method declaration (as seen in the snippet below):

-(void)myOldMethod __attribute((deprecated("Use the myNewMethod instead.")));

Now when you call myOldMethod in your code, the compiler will warn you that: “myOldMethod is deprecated. Use the myNewMethod instead”. You can also add the deprecated attribute to property declarations.

But what if you wanted to be more specific? For instance, if there is a better way to handle something in the iOS 8 SDK, you can mark an old method as deprecated only for projects that have iOS 8.0 or later as the deployment target.

-(void)myOldMethod NS_DEPRECATED_IOS(3_0, 8_0,"Use myNewMethod instead.");

Using the code snippet above, if you call myOldMethod the compiler will only warn you that the method is deprecated if your project’s deployment target is set to iOS 8 or later.

Deprecating your own methods can come in handy especially if you have written your own framework that is used across multiple projects. You may choose to deprecate some of your own API rather than removing the methods entirely until you get around to modifying your existing projects to use your new API.

iOS Devices: Screen Bounds List

Dimensions (in points):

*Note: Starting in iOS 8, the bounds property on UIScreen is orientation based, so for example if the bounds in portrait mode is 320×480, in the landscape orientation the bounds would be 480×320. The list below assumes that the device is in the portrait orientation.

320 x 480
-iPhone 4s and earlier models.
320 x 568
-iPhone 5
-iPhone 5S
-iPhone 5C
375 x 667
-iPhone 6
414 x 736
-iPhone 6 Plus
768 x 1024
-iPad