Nick Harris

Posts Tagged ‘Code

UIAlertView with an NSObject

with 3 comments

Here’s my situation… I have an operation that gets performed in the background. If that operation fails I need to alert the user and see what they would like to do about it. If they want to retry it, I just add the operation back onto the queue.

To do this, I’m sending a notification that the operation failed and am including the operation as the notifications object. I then set up a responder on my view controller for that notification. It creates a UIAlertView to ask the user what to do.

If the user selects “Retry”, it would be nice to have the operation right there on the alert view in alertView:clickedButtonAtIndex: so that I can just add it back to the operation queue. But there doesn’t seem to be any properties on UIAlertView for an arbitrary object. Instead I’ve subclassed UIAlertView and simply added a NSObject property.

Pretty easy code wise, just wondering if I’m missing something on UIAlertView that would handle the same thing.

Written by Nick Harris

March 26, 2010 at 5:00 pm

Posted in Code

Tagged with