On Demand Resources
Story Tellers iOS Starter Kit Documentation
We can drip content to iOS9 users by adding On Demand Resource Tags. Content includes: images, folders of images, movie, sound files, you know, the big stuff. In the image below, you’ll see I’ve selected an image named Map, which is a slightly heftier file size compared to some others. Then in Xcode 7’s Attributes Inspector (circled in the top right), I’m giving it an On Demand Resource Tag name of MapTag.
So that’s how tagging works. Its quick. Simple, and kinda fun actually. Plus Apple is going to host all your tagged content for you. So even though you could host it yourself (I won’t get into that), Apple has made it a no-brainer to tag your content and let them worry about delivering it.
Now that you’ve tagged a bunch of stuff…
Let’s think about when we need to present that content to the user. In Xcode 7 head over to the Resource Tags pane in your project settings (see the image below for reference) and take a look at where that MapTag ended up from the previous image…
By default the MapTag was added to the Download Only On Demand fold-down, which is probably where we want it. You could though drag the tag into the other two options. Let’s talk about all three….
- Initial Install Tags sounds like exactly what it is: tags here are for content that will be installed initially by default. I wouldn’t worry about tagging your initial content though, because by NOT tagging it, it will be in the bundle like usual. And let’s assume you always want your app’s users to be able to go back to the intro screen, cover page, whatever and not worry about that content possibly being purged.
- Prefetched Tag Order is for tagged content you don’t want to include in the initial install of the app, but you want this content to begin downloading immediately after the reader begins using the app / after it is installed (I’m not exactly sure which). The content is downloaded in the same order you list it (from top to bottom). This is a nice option if you want to get your initial binary size below, say, 20MB, but have another 70MB that won’t get used right away. It could still be essential content for the app, but as long as it isn’t needed in the start screen or first few game levels, you could safely exclude it.
- Download Only On Demand is ideally what you’ll want if you don’t think the user can quickly get to the content after downloading the app. For example, if your puzzle book app has a natural reading order, and the reader can’t simply jump from Page 1 to Page 10. Perhaps they have to unlock pages 2-9 before 10 is even accessible. In this case, you can safely set that content to be downloaded as needed. For example, if the reader gets to Page 8, you might then began downloading tagged content for Page 10 since they are only a couple pages away (and you might want to give them a little buffer time in case their internet connection is slow).
Requiring Tagged Content in the Kit
By adding an Array named ResourceTags and listing tag names, your page now knows that the tagged content (matching the array strings) is required for this page to open.
Preloading Tagged Content
You can preload content from any page by using the PreloadResourceTags property. Again, this can be an array to list multiple tags, like so…
So in the example above, we are preloading the MapTag, and this would be done assuming that the reader is close to opening a page that includes the MapTag content.
If you stumbled onto this article, it is part of our documentation for the Story Tellers iOS Starter Kit 2. The kit enables you to make children’s book apps and games without writing any code! But it is Swift 2 based and compatible with iOS9 (or higher) and Xcode 7 (or higher), so kit buyers can even extend the functionality to fit their needs further. Some of what we cover in the kit documentation may apply to Xcode in general, so this article could be worth a read even if you aren’t a user. You can purchase Lifetime Updates the kit here, or subscribe Yearly to CartoonSmart and get the latest version, plus access to all of our other kits / tutorials.
We’ve also created an iBook to document the very latest properties in the kit, so be sure to download that as well.