- #SWIFT SHARE DATA WITH PDF UPDATE#
- #SWIFT SHARE DATA WITH PDF CODE#
- #SWIFT SHARE DATA WITH PDF DOWNLOAD#
Let book = try? JSONDecoder().decode(lf, from: data)
#SWIFT SHARE DATA WITH PDF CODE#
Importing App Dataīefore you can handle opening data from the file, you’ll need some code that can work with the file that you have passed to it.Īdd that code by opening Book.swift, and replacing importData(from:) with the following: Note: If you don’t see “Copy to Book Tracker” displayed in UIActivityViewController after tapping the attached file in your email, you may need to edit the order of supported apps by scrolling to the end of the list, selecting More, and moving “Copy to BookTracker” to the top of the list. Now that you’re a UTI wizard, it’s time for you to sprinkle some magic. However, it won’t load the data from the sample file because you haven’t implemented the code for that yet. Selecting Book Tracker will open the app. You can tap on the attachment and it will prompt you to open the book in the Book Tracker app. Otherwise, both the file extension UTI and mime type will be wrong. Please make sure you unzip the file before emailing it to yourself.
#SWIFT SHARE DATA WITH PDF DOWNLOAD#
You can test this out by emailing yourself a copy of the Swift Apprentice.btkr file from the Download Materials resource. btkr or files that have a mime type of application/booktracker.īelieve it or not, by setting these keys, you have told iOS to start sending your app files that end with the. Here you define that your app can handle files ending in.
To set up sharing inside your app, you’ll have to configure some keys inside your app’s ist and handle a few system callbacks inside your app’s AppDelegate. You’ll learn everything you need to know to use this class in this UIActivityViewController tutorial! It may even net you some new customers!įortunately, since iOS 6, Apple has provided the handy, but much-overlooked, UIActivityViewController class, which offers a clean interface for sharing and manipulating data inside your app. Sharing is a convenient way for users to send data to each other or between devices. Andy Pereira wrote the original.Ī lot of developers want to be able to share their app data via email, Messages or AirDrop.
#SWIFT SHARE DATA WITH PDF UPDATE#
Update note: Owen L Brown updated this tutorial for Xcode 10.1, Swift 4.2, and iOS 12.