Recently in the UIKit framework
UIActivityItemProvider's item property was declared as nonnull.The problem is that the actual item may not be available at this time and the app has no way to abort the process.
Let's take a photo app for example which allows sharing photos:
- An empty
is used as placeholder item to indicate that the app can share an image.UIImage - Once the user selects an activity, the app tries to download the fullsize image before returning it from
'sUIActivityItemProvider
property.item - The download may fail in which case the app is unable to continue since item expects a non-nil return value.
- The app could either crash or return some garbage
which iOS would then share with the destination app.UIImage
How are we supposed to implement the
item property in cases where the retrieval of the item can fail?