2012-06-22 14 views
2

我們如何訪問Mac OS應用程序的Pref Pane Bundle? 我已將圖像和其他資源放置在pref窗格包內,但我無法獲取路徑:使用: NSString * path = [[NSBundle mainBundle] pathForResource:@「tick」ofType:@「png」];如何訪問pref窗格包?

其中tick.png存在於NewPrefPane.prefPane資源文件夾

回答

7

[一個NSBundle mainBundle]

返回一個NSBundle以來,該系統預置應用程序是一個,實際上是運行你的窗格。

使用方法,如果你只需要在你的NSPreferencePane類:

[self bundle] 

使用bundleForClass在窗格中代碼的其他地方:

NSString * path = [[NSBundle bundleForClass:[self class] pathForResource:@"tick" ofType:@"png"];