2010-12-27 8 views
1

Ich habe ein "Preference Pane" -Projekt erstellt. In diesem Projekt möchte ich ein Bild aus meinem Bundles-Ressourcenordner laden. Dies scheint schwierig, weil „[NSBundle main]“ folgende zurückzukehren scheint:Xcode - "Preference Pane" -Projekt - wie auf Bundle zugreifen?

27/12/10 9:24:18 PM System Preferences[5076] NSBundle </Applications/System Preferences.app> (loaded) 

Iterieren durch „[NSBundle allBundles]“ zeigt, dass meine Projekte Bündel erscheint, aber erscheint nicht geladen werden:

27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/Mouse.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/Sound.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/Spotlight.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/TimeMachine.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </Library/PreferencePanes/DivX.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/Trackpad.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/UniversalAccessPref.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/Dock.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/DateAndTime.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/Keyboard.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/MobileMe.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/FibreChannel.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/Appearance.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/DigiHubDiscs.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/Ink.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/Security.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/EnergySaver.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/Speech.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </Users/michael/Library/PreferencePanes/MyPrefPane.prefPane> (loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </Users/michael/Code/MyPrefPane/build/Debug/MyPrefPane.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/SharingPref.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/Expose.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/SoftwareUpdate.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/ParentalControls.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/PrintAndFax.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/Accounts.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/DesktopScreenEffectsPref.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/Bluetooth.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/Localization.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/StartupDisk.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/Network.prefPane> (not yet loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </Applications/System Preferences.app> (loaded) 
27/12/10 9:24:18 PM System Preferences[5076] NSBundle </System/Library/PreferencePanes/Displays.prefPane> (not yet loaded) 

Ich bin mir nicht sicher, was hier los ist. Wie kann ich auf mein Prefunebündel zugreifen?

Antwort

2

Aufruf [self bundle] innerhalb Ihrer Hauptklasse sollte es tun.

+0

hier Dokumentiert: http://developer.apple.com/library/mac/documentation/UserExperience/Reference /PreferencePanes/Classes/NSPreferencePane_Class/Reference/Reference.html#//apple_ref/occ/instm/NSPreferencePane/bundle –

1

Ich denke, Sie müssen "[NSBundle bundleForClass: [Selbst Klasse]];".

0

Späte Antwort aber für Leute, die nach einer vollen Lösung suchen. Wenn Sie eine Bildressource in Ihrem prefpane Bündel namens red.png hatte, konnte man die Ressource geladen werden durch den Aufruf der folgende:

NSImage *redIndicator = [[self bundle] imageForResource:@"red"];