我有一個應用程序使用多個模態表單進行數據輸入。打開模式表的方法運行良好,並且仍然正常工作,但它們已被棄用,我擔心它們很快就不能用於未來的Xcode版本。 Here, Apple points out how to use modal sheets,打開10.9的模態表格
- (void)showCustomSheet: (NSWindow *)window
// User has asked to see the custom display. Display it.
{
if (!myCustomSheet)
//Check the myCustomSheet instance variable to make sure the custom sheet does not already exist.
[NSBundle loadNibNamed: @"MyCustomSheet" owner: self];
[NSApp beginSheet: myCustomSheet
modalForWindow: window
modalDelegate: self
didEndSelector: @selector(didEndSheet:returnCode:contextInfo:)
contextInfo: nil];
// Sheet is up here.
// Return processing to the event loop
}
但在Xcode 5.1的發佈,他們確定了loadNibNamed方法已經過時,我們應該使用類似功能指引頂級對象。
我遇到的問題,正在改變這一點:
[NSBundle loadNibNamed:@"OrderDetailsWindow" owner:self];
到這一點。
NSArray *array;
[[NSBundle mainBundle]loadNibNamed:@"OrderDetailsWindow" owner:self topLevelObjects:&array];
此方法調用確實會打開模態表單。但是,在我的方法結束時,打開模式表單,Xcode掛起這個錯誤。
0x7fff8c33b097: andl 24(%r11), %r10d Thread1: EXC_BAD_ACCESS (code:EXC_I386_GPFLT)
我不確定這是告訴我什麼。它在調試區域中沒有提供任何信息。這可能與topLevelObjects數組未正確釋放有關嗎?有關如何使這項工作更順利一點的想法?蘋果過時的圖書館讓我瘋狂!
您使用的是Xcode 5.1嗎? –
是的,我正在使用5.1。 – Breeze73
如果您使用的是Xcode 5.1,那麼您必須在Apple工作。我們其餘的人都在使用Xcode 5.0.1。僅供參考 - 您的問題與Xcode無關。任何棄用的東西都與Cocoa框架的API版本有關。 – rmaddy