0

我希望将此代码从 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];
4

1 回答 1

1

informativeText不可变(从来没有)

[alertSheet setInformativeText:[NSString stringWithFormat:@"Informative text PJ%@-%@ with more text.",  self.projectNumber,self.projectName]];

您还可以使用点符号

alertSheet.informativeText = [NSString stringWithFormat...
于 2016-11-23T20:21:31.830 回答