Mục đích của MVC là làm cho các đối tượng thực hiện các loại mã như khác biệt với nhau càng tốt. Bất cứ đối tượng nào bạn viết nên được dễ dàng nhận dạng là thuộc vào một trong ba loại, với rất ít hoặc không có chức năng bên trong nó có thể được phân loại trong một trong hai. x | 90 CHAPTER 4 More User Interface Fun UIActionSheet actionSheet UIActionSheet alloc initWithTitle @ Are you sure delegate self cancelButtonTitle @ No Way destructiveButtonTitle @ Yes I m Sure otherButtonTitles nil The initializer method took a number of parameters. Let s look at each of them in turn. The first parameter is the title to be displayed. If you look at Figure 4-3 you can see how the title we re supplying will be displayed at the top of the action sheet. The next argument is the delegate for the action sheet. The action sheet s delegate will be notified when a button on that sheet has been tapped. More specifically the delegate s actionSheet didDismissWithButtonIndex method will be called. By passing self as the delegate parameter we ensure that our version of actionSheet didDismissWithButton Index will be called. Next we pass in the title for the button that users will tap to indicate they do not want to proceed. All action sheets should have a cancel button though you can give it any title that is appropriate to your situation. You do not want to use an action sheet if there is no choice to be made. In situations where you want to notify the user without giving a choice of options an alert sheet is more appropriate. We ll see how to use alert sheets in a bit. The next parameter is the destructive button and you can think of this as the yes please go ahead button though once again you can assign any title to it that is appropriate to your situation. The last parameter allows us to specify any number of other buttons that we may want shown on the sheet. This final argument can take a variable number of values which is one of the nice features of the Objective-C language. If we had wanted two more buttons on our action sheet we could have done it like this UIActionSheet actionSheet UIActionSheet alloc initWithTitle @ Are you sure delegate self cancelButtonTitle @ No Way destructiveButtonTitle @ Yes I m Sure otherButtonTitles @ Foo @ Bar nil This code would