Hello,
I am working on an application in which I want to display an alert message when the user presses a button. So far, I have following code for the alert message itself:
NSString *userText = [NSString stringWithFormat:@"Hello %@", self.nameBox.text];
UIAlertController *alertMessage = [UIAlertController alertControllerWithTitle:@"Welcome to iOS"
message:userText
preferredStyle:UIAlertControllerStyleActionSheet];I understand what is going on here, where I am confused is the alertWithTitle:style:handler method, specicially the handler parameter. I have code posted online where they wrote in
^(UIAlertAction * action)UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel"
style:UIAlertActionStyleCancel
handler:nil];I passed in nil, Is this a bad practice, also, could someone explain what this line means and why it should be used instead: ^(UIAlertAction * action)