如果您的應用將支持獅子,那麼loadNibNamed:owner:topLevelObjects:
將不火,當上獅跑,你會得到一個異常(無法識別的選擇)。一些周圍搜索後,我來到了這一點:
// loadNibNamed:owner:topLevelObjects was introduced in 10.8 (Mountain Lion).
// In order to support Lion and Mountain Lion +, we need to see which OS we're
// on. We do this by testing to see if [NSBundle mainBundle] responds to
// loadNibNamed:owner:topLevelObjects: ... If so, the app is running on at least
// Mountain Lion... If not, then the app is running on Lion so we fall back to the
// the older loadNibNamed:owner: method. If your app does not support Lion, then
// you can go with strictly the newer one and not deal with the if/else conditional.
if ([[NSBundle mainBundle] respondsToSelector:@selector(loadNibNamed:owner:topLevelObjects:)]) {
// We're running on Mountain Lion or higher
[[NSBundle mainBundle] loadNibNamed:@"NibName"
owner:self
topLevelObjects:nil];
} else {
// We're running on Lion
[NSBundle loadNibNamed:@"NibName"
owner:self];
}
如果你真的想用topLevelObjects:&array
的山獅+,你也想支持獅子,它看起來像你需要依傍loadNibFile:externalNameTable :withZone:(可作爲一個類和實例方法)爲獅子條件(我可能是錯誤的這一個)。我得到的印象是loadNibNamed:owner:topLevelObjects:
是爲了取代這個而創建的。
我也讀過其他地方,當使用較新的loadNibNamed:owner:topLevelObjects:
作爲表單時,您應該取消選中「關閉時釋放」表單(窗口)。
[self.sheet close];
self.sheet = nil;
我不知道到底是什麼應該有關複選框,如果你打開一個非模態窗口中完成:當您關閉表這應該被照顧的。有任何想法嗎?
考慮將自定義工作表部分拆分爲它自己的單獨問題:實現自定義工作表的最佳方法是什麼?將是一個很好的標題。 – alfwatt