In my application i have an UIViewController
that i uses a lot of UIAlertView
to ask things to the user.
Because i need the response of each UIAlertView
i have made my controller a delegate of UIAlertViewDelegate
, this works fine but after 7 UIAlertView
's i`m trying to find a better way to use delegates.
In java i know that i can create inline classes for a single purpose, like in this question: Java - inline class definition
What i want to know is: Is there a way to create a class to be delegate dynamically? to achieve something like this
id<UIAlertViewDelegate> myCustomClass = @class {
my class code goes here
}
UIAlertView* alertView;
alertView = [[UIAlertView alloc] initWithTitle:@"Title"
message:@"Message"
delegate:myCustomClass
cancelButtonTitle:@"No"
otherButtonTitles:@"OK", @"Sure", @"Maybe", nil] ];
[alertView show];