此調用爲「安全」,但僅爲10.9+。這是頭文件:
#if NS_BLOCKS_AVAILABLE
- (void)beginSheetModalForWindow:(NSWindow *)sheetWindow completionHandler:(void (^)(NSModalResponse returnCode))handler NS_AVAILABLE_MAC(10_9);
#endif
看來,他們只是不小心留下它當前文檔的。然而,標題通常被認爲是Cocoa的「真相」,它們權威地告訴你什麼是廢棄和什麼是新的。 (不同於X11,例如,當文檔被宣佈爲在實際的實施方案或頭部正確)
這些都是常量要將completionHandler塊中使用:
/* These are additional NSModalResponse values used by NSAlert's -runModal and -beginSheetModalForWindow:completionHandler:.
By default, NSAlert return values are position dependent, with this mapping:
first (rightmost) button = NSAlertFirstButtonReturn
second button = NSAlertSecondButtonReturn
third button = NSAlertThirdButtonReturn
buttonPosition 3+x = NSAlertThirdButtonReturn + x
Note that these return values do not apply to an NSAlert created via +alertWithMessageText:defaultButton:alternateButton:otherButton:informativeTextWithFormat:, which instead uses the same return values as NSRunAlertPanel. See NSAlertDefaultReturn, etc. in NSPanel.h
*/
enum {
NSAlertFirstButtonReturn = 1000,
NSAlertSecondButtonReturn = 1001,
NSAlertThirdButtonReturn = 1002
};
我m建立在運行10.9的機器上,但指定了10.6作爲部署目標。這是否意味着當我最終在10.6機器上進行測試時,這會失敗? – MikeMayer67
是啊,你必須使用10.6的舊方法,否則會崩潰。很愚蠢,當你使用「太新」的方法時,沒有任何警告,但這是他們的決定。 –