XCode 7 中的 NSAlert
NSAlert in XCode 7
我希望将此代码从 10.8 更新到 10.11。这是原始代码。
NSAlert *alertSheet = [NSAlert alertWithMessageText:@"Message Text." defaultButton:@"OK" alternateButton:nil otherButton:nil informativeTextWithFormat:@"Informative text PJ%@-%@ with more text.", self.projectNumber,self.projectName];
[alertSheet setAlertStyle:NSCriticalAlertStyle];
[alertSheet beginSheetModalForWindow:self.window modalDelegate:nil didEndSelector:nil contextInfo:nil];
部分代码已弃用。这是我目前所做的,但它不起作用。
NSAlert *alertSheet = [[NSAlert alloc]init];
[alertSheet setMessageText:@"Message Text."];
[alertSheet setInformativeText:@"Informative text PJ%@-%@ with more text.", self.projectNumber,self.projectName];
[alertSheet beginSheetModalForWindow:self.windowPreferences completionHandler:nil];
informativeText
不是可变参数(从来没有)
[alertSheet setInformativeText:[NSString stringWithFormat:@"Informative text PJ%@-%@ with more text.", self.projectNumber,self.projectName]];
您也可以使用点符号
alertSheet.informativeText = [NSString stringWithFormat...
我希望将此代码从 10.8 更新到 10.11。这是原始代码。
NSAlert *alertSheet = [NSAlert alertWithMessageText:@"Message Text." defaultButton:@"OK" alternateButton:nil otherButton:nil informativeTextWithFormat:@"Informative text PJ%@-%@ with more text.", self.projectNumber,self.projectName];
[alertSheet setAlertStyle:NSCriticalAlertStyle];
[alertSheet beginSheetModalForWindow:self.window modalDelegate:nil didEndSelector:nil contextInfo:nil];
部分代码已弃用。这是我目前所做的,但它不起作用。
NSAlert *alertSheet = [[NSAlert alloc]init];
[alertSheet setMessageText:@"Message Text."];
[alertSheet setInformativeText:@"Informative text PJ%@-%@ with more text.", self.projectNumber,self.projectName];
[alertSheet beginSheetModalForWindow:self.windowPreferences completionHandler:nil];
informativeText
不是可变参数(从来没有)
[alertSheet setInformativeText:[NSString stringWithFormat:@"Informative text PJ%@-%@ with more text.", self.projectNumber,self.projectName]];
您也可以使用点符号
alertSheet.informativeText = [NSString stringWithFormat...