// 创建一个NSAlert,并以Sheet的形式呈现-(IBAction)removeRow:(id)sender{NSAlert*alert=[NSAlertalertWithMessageText:@"Are you sure?"defaultButton:@"Yes"alternateButton:@"No"otherButton:nilinformativeTextWithFormat:@"Deleting a table cell is not reversable."];[alertbeginSheetModalForWindow:self.windowmodalDelegate:selfdidEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)contextInfo:NULL];}// NSWindowDelegate方法,用来指定Sheet的显示位置-(NSRect)window:(NSWindow*)windowwillPositionSheet:(NSWindow*)sheetusingRect:(NSRect)rect{idcell=[self.tableViewrowViewAtRow:[self.tableViewselectedRow]makeIfNecessary:YES];NSRectcellRect=[cellframe];NSRectscrollViewRect=[self.tableView.superviewframe];cellRect.origin.y=scrollViewRect.size.height-cellRect.origin.y;// View-based table view is flipped?cellRect.size.height=0;returncellRect;}