March 24, 2016

Utilizing On-Demand Resources

Thibault Klein
iOS Engineer

On-Demand Resources, introduced by Apple at WWDC 2015 for iOS 9, allows you to separate specific assets of your app from the main bundle and dynamically download them only when needed, allowing better utilization of storage space. All assets are hosted on the App Store so you don’t need to worry about it. The resources can be mostly anything, with the exception of executable code.

The results are incredibly beneficial as described by Apple in their documentation:

On-Demand Resources are very powerful for almost any Apple TV apps since a tvOS bundle has a hard limit of 200MB. Recently, at the Apple TV Tech Talks in NYC, Apple gave some tips on how to take advantage of On-Demand Resources.

Purge assets

You can mark assets that are not required as unused so the system knows what to remove first. If a file is marked as unused you should assume that this asset is not available anymore, so you may have to download it again.

You can also set a priority order to purge your unused assets. You can assign a value from 0 (normal) to 1 (highest), and the system will determine what assets need to be removed first.

Tagging

You can tag your files to categorize them. For example in a video game, “Level 1” and “Level 2” are common tags that you can use. Remember that you can tag files or folders. You can assign a file multiple tags too, in the event a file is reused in various places.

You can use special tag categories to help the system prioritize the download:

Flow

Here is the basic flow to get data through On-Demand Resources:

You can set a relative priority of simultaneous requests to help the system prioritize the download. The values goes from 0 (normal) to 1 (urgent). You can also further mark an asset as incredibly urgent priority when the user is blocked waiting for a request to complete; doing so will suspend all the non-urgent requests and download the urgent assets regardless of CPU usage.

Conclusion

If you want more information about On-Demand Resources and how to set everything in your project, I highly recommend reading Apple’s documentation.

As you can see, On-Demand Resources is a great way to deal with a large amount of assets and dynamically control them based on the user’s need. It is very useful for any app that needs to store a lot of assets and allows the developer to more properly manage the user’s device storage.

Share Button

Utilizing On-Demand Resources

iOS Engineer

On-Demand Resources, introduced by Apple at WWDC 2015 for iOS 9, allows you to separate specific assets of your app from the main bundle and dynamically download them only when needed, allowing better utilization of storage space. All assets are hosted on the App Store so you don’t need to worry about it. The resources can be mostly anything, with the exception of executable code.The results are incredibly beneficial as described by Apple in their documentation:

On-Demand Resources are very powerful for almost any Apple TV apps since a tvOS bundle has a hard limit of 200MB. Recently, at the Apple TV Tech Talks in NYC, Apple gave some tips on how to take advantage of On-Demand Resources.

Purge assets

You can mark assets that are not required as unused so the system knows what to remove first. If a file is marked as unused you should assume that this asset is not available anymore, so you may have to download it again.You can also set a priority order to purge your unused assets. You can assign a value from 0 (normal) to 1 (highest), and the system will determine what assets need to be removed first.

Tagging

You can tag your files to categorize them. For example in a video game, “Level 1” and “Level 2” are common tags that you can use. Remember that you can tag files or folders. You can assign a file multiple tags too, in the event a file is reused in various places.You can use special tag categories to help the system prioritize the download:

Flow

Here is the basic flow to get data through On-Demand Resources:

You can set a relative priority of simultaneous requests to help the system prioritize the download. The values goes from 0 (normal) to 1 (urgent). You can also further mark an asset as incredibly urgent priority when the user is blocked waiting for a request to complete; doing so will suspend all the non-urgent requests and download the urgent assets regardless of CPU usage.

Conclusion

If you want more information about On-Demand Resources and how to set everything in your project, I highly recommend reading Apple’s documentation.As you can see, On-Demand Resources is a great way to deal with a large amount of assets and dynamically control them based on the user’s need. It is very useful for any app that needs to store a lot of assets and allows the developer to more properly manage the user’s device storage.

Share Button

Comments are closed.