Re: Custom component fails to load images by name in a IBPlugin
Re: Custom component fails to load images by name in a IBPlugin
- Subject: Re: Custom component fails to load images by name in a IBPlugin
- From: "Dalzhim Dalzhim" <email@hidden>
- Date: Fri, 19 Sep 2008 15:56:43 -0400
Hello Chris,
I have tried looking for the image in the bundle of my custom component's class but that doesn't work in Interface Builder neither in my own application. My guess is that the bundle of my custom component is a bundle specific to my framework. A project which links against that framework remains in a separated bundle and thus looking for the image in the custom component's bundle fails when trying to use images introduced by the application.
It is true that using mainBundle must be returning Interface Builder's bundle instead of the application's bundle, but that solution works in the final application unlike the bundleForClass method, unless I have misunderstood which MyView class you were talking about. Thanks for helping me with this.
regards
-Dalzhim
2008/9/19 Chris Hanson
<email@hidden>
On Sep 19, 2008, at 10:21 AM, Dalzhim Dalzhim wrote:
I have packaged this component in a IBPlugin and designed a custom inspector to configure my custom component at design time by entering the names of the required images. However, my component fails to load the images when it is being configured in Interface Builder. It also used to fail to load when I ran the application which uses the framework which includes this ibplugin, but I already fixed that by searching for the image in the mainBundle.
When your plug-in is run under Interface Builder, +[NSBundle mainBundle] will return Interface Builder's bundle rather than your application's bundle. Your view might want to look for the resources in its bundle — e.g., the bundle returned by [NSBundle bundleForClass:[MyView class]] — for its images.
That way, when your view class is compiled into the Interface Builder plug-in it will look in the plug-in for its images, and when it's compiled into your application it will look in your application for its images. And if you move your view to a framework that's used by both your application and your Interface Builder plug-in, you can move its images along with it and they'll be found there as well.
-- Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden