With less than 3 days left till the Apple keynote, developers are rushing to adapt their Apps for iOS 8. If you, like me, happen to be very busy these days with your normal app development flow, you know how hard it is having to look at all the API changes and going through the code of all your Apps, checking all possible loose ends. No matter how hard you try, there always seems to be something that escapes your scrutiny.

These are some necessary adjustments that I have found to be hard to trace or locate unless you happen to stumble upon them. Make sure to check for them in your Apps, as they could render them inoperative or be the cause of hard to debug errors.

❤️ Enjoying this post so far?

If you find this content useful, consider showing your appreciation by buying me a coffee using the button below 👇.

Buy me a coffeeBuy me a coffee

Registering for push notifications on iOS 8

The UIApplication instance method registerForNotificationsType:, used for registering your application to receive remote (push) notifications, has been deprecated. The bad news is that the debugger won’t warn you about this, and the application will only issue a console warning in runtime, something very easy to overlook.

Apple has introduced the concept of “user notification settings”, a set of options that indicates how remote notifications can interact with the user by means of your App. These settings include the old notification types (like UIRemoteNotificationTypeBadge or UIRemoteNotificationTypeSound). Thus, starting with iOS 8, in order to register for remote notifications, we must specify the notification types in our user’s notification settings and then simply register for notifications. If you want your notifications to work properly for both iOS 7 and iOS 8, you can implement it using precompiler #ifdef statements:

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
    [[UIApplication sharedApplication] registerUserNotificationSettings:
        [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge | 
                                                      UIRemoteNotificationTypeSound | 
                                                      UIRemoteNotificationTypeAlert) categories:nil]];
    [[UIApplication sharedApplication] registerForRemoteNotifications];
} else {
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(
        UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
}
#else
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(
        UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
#endif

You cannot embed custom UIViews (like a UIDatePicker) inside a UIActionSheet anymore

timeOne of my favorite ways of presenting a UIDatePicker when the user presses a button was by means of a UIActionSheet. Well, it seems that we cannot use it anymore for this duties, as Apple points out in its documentation:

UIActionSheet is not designed to be subclassed, nor should you add views to its hierarchy. If you need to present a sheet with more customization than provided by the UIActionSheet API, you can create your own and present it modally with presentViewController:animated:completion:.

So, what can we do now? It depends on the application. For some of my apps, I have resorted to a PopUp-style animating UIView, for another Apps, I have decided to implement a new UIViewController with a custom transition. You will need to find the way that best suits your current UX and the flow of your application. It is funny, however, how easy it is to overlook this one unless you touch a button or trigger an action where you used this technique.

UITabBarItem settings and appearance

Recently, when debugging one of my Apps for iOS 8, I noticed that the UITabBar items where not applying my custom appearance settings. Upon research, I finally discovered that the method I was using: setFinishedSelectedImage:withFinishedUnselectedImage:, had been actually deprecated on iOS 7. It’s weird that XCode hadn’t warned me, and I had no indication, warning or anything from the compiler regarding this deprecation. Finally, for iOS 8, the method is not working at all, so if you want to customize the images for your UITabBarItems, you must replace setFinishedSelectedImage:withFinishedUnselectedImage: with image and selectedImage using UIImageRenderingModeAlwaysOriginal. So you will replace this call:

UIImage * selectedItemImage = ...
UIImage * unselectedItemImage = ...
[(UITabBarItem *) [self.tabBar.items objectAtIndex:0] setFinishedSelectedImage:selectedItemImage 
       withFinishedUnselectedImage:unselectedItemImage

with this one:

[(UITabBarItem *) [self.tabBar.items objectAtIndex:0] setImage:unselectedItemImage 
      imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[(UITabBarItem *) [self.tabBar.items objectAtIndex:0] setSelectedImage:selectedItemImage 
      imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

One more thing?

I am really excited about the Apple keynote of September the 9th, I can’t wait to watch the new iPhone 6, which is rumored to have a bigger screen as part of a fully overhauled design. I also expect Apple to unveil the much-rumored iWatch and maybe iPads with touchID. If Apple finally releases a watch device, it is going to open a new world of possibilities for us, developers. I can’t hardly wait for the event to start.

Am I missing something? Do you have some obscure method or functionality that has been deprecated or is not working anymore on iOS 8? Please let us know in the comments!