Tag: Tutorial

  • Code Snippet: UIAlertController Error Extension

    It is an essential part of software development to handle errors correctly and iOS development is no different. It is important to reduce the impact of the error to your user and inform your user clearly if an action is required.

    Here is the extension that you will need to add to your project and the implementation of how you would present the UIAlertController within a UIViewController class.

    https://gist.github.com/rtking1993/26a4d36a69563f38f5e726949b6edd67

  • Tutorial: Creating an iOS Share Sheet

    iOS share sheets are a great way to allow your users to share content from your app. This is a great way to provide your users with the ability to share your app with their network of friends and family for you. A recommendation from somebody you trust is both more powerful than an advertisement and free for the app owner. It is also very easy to do.

    Tutorial

    Firstly, add this extension to the UIViewController to your project. It requires you to pass in your object and will present a share sheet for this object on the active UIViewController.

    https://gist.github.com/rtking1993/36e4191190bff961c0d901640b572ffd

    Next, we have the implementation, we want to create an object with three parameters (text, image, and url), then we call our presentShareSheet function from our extension.

    https://gist.github.com/rtking1993/3b6b1e7d5c7a1ca6aebd41dd163d1b87

    As you can see we are doing this inside an IBAction, so we can create the share sheet whenever we like. And something like the image below is what you should see.

     

    The full source code for a test project I have created for displaying iOS share sheets is available:

    https://github.com/rtking1993/ShareSheet