UIAlertView has been deprecated by Apple from iOS8. From now on, UIAlertController is the way to go.
UIAlertController is surly an improvement, but given the asynchronous nature of displaying alerts to the user, I wanted to us the API together with async and await.
Below is a screenshot of what I wanted to accomplish:
A simple menu with two options and a Cancel-button.
By using a TaskCompletionSource, I can accomplish this using async and await.
TaskCompletionSource can be used to map an external asynchronous operation onto a normal C# Task. We can then use this task as we would any other.
In this case, the result of this task is the Enum
CustomerFeeling with values corresponding to the users happiness. Thus,
ShowRatingDialogAsync can be used like this:
The choice of the user can be awaited and
UIAlertController now fits in perfectly with the rest of the C# code.
(If you liked this, you might enjoy New Features in FermiContainer 1.1.)