O'Reilly logo

iOS 8 Swift Programming Cookbook by Vandad Nahavandipoor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. Extensions

2.0. Introduction

Since the introduction of iOS, Apple has been very cautious about opening it up to developers to extend the system. The reason, at least officially, was that Apple wanted to find the right way of allowing access without compromising the security of user content and the system as a whole. In version 8 of iOS, developers are given a bit more control over how we can use iOS to provide content to the user. For instance, you can build custom keyboards or provide custom sharing extensions to the user.

To make an extension available to users, your app instantiates an object of type UIActivityViewController and displays it on the screen like you would display any other view controller. When this view controller is displayed on the screen, iOS will look at all the extensions that are currently installed on the system and will display a sheet similar to that shown in Figure 2-1.

These are simply extensions provided by the system and third-party providers. The ones on top are sharing extensions and the ones on the bottom are action extensions. Sharing extensions, as the term suggests, take in content, such as a photo or text, and allow the user to share that item with others. For instance, if you open a photo, you can then directly share that with your followers on Twitter. Action extensions are those that perform some work on the item that is being shared and return immediately. For instance, you might want to provide a action extension that is called ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required