• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Custom component fails to load images by name in a IBPlugin
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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: Mon, 22 Sep 2008 19:37:32 -0400

2008/9/22 Jonathan Hess <email@hidden>

Hey Dalzhim -

IB does automatically load the plug-ins embedded in the resources of frameworks that are linked by your project, but it still depends on those plug-ins and their frameworks living at their installed location. The problem you're experiencing is because the framework and plug-in are in your build directory, not their installed location. The "sudo xcodebuild install" followed by the ditto places a copy of the frameworks and plug-ins in their installed locations. 

It should be possible to configuring the @rpath settings of your plugin so that it can be loaded either from the build directory or the install location and always find the nearby framework. However, I don't know enough about rpath relative linking to give you explicit instructions.

Dear Jon,

I guess I should be restoring the installation path for my framework (in the release configuration at least) to /Library/Frameworks so that this procedure can work?  Because right now with my @loader_path/../Frameworks configuration I end up with weird results when using "sudo xcodebuild install".  I will try and google more information and hopefully, examples about this @rpath setting as having the plugin load dynamically from a linked-in framework was the feature that made me decide to build a framework with custom components as it seemed very user-friendly when working over source control.
 


The object you pass in as the argument to documentForObject: needs to be one of the objects that appears in the document outline view in Interface Builder.  If [IBDocument documentForObject:object] is returning nil, then that means the object you passed in as an argument isn't in a document. For example, it would return nil if you passed in your inspector, or a private helper object of your view that isn't in your Interface Builder document. -[IBInspector document] is an alternative way to retrieve the inspected document.

If the object I was integrating was a 'MyView' and it had an image property, I might implement it like this.

@implementation MyWidget(IBInspectorAdditions)
- (NSString *)inspectedImageName {
    return [[self image] image];
}

- (void)setInspectedImageName:(NSString *)name {
    IBDocument *document = [IBDocument documentForObject:self];
    [self willChangeValueForKey:@"inspectedImageName"];
    [self setImage:[document documentImageNamed:name]];
    [self didChangeValueForKey:@"inspectedImageName"];
}
@end

Then I would bind my inspector to the File's Owner's "inspectedObjectsController.selection.inspectedImageName". 



That code looks fine, it must be the case that 'self' isn't a object in an IBDocument. Do you see it in the outline view of the document window?

Jon Hess

 
Thanks to your example I have fixed the problem!  The lines of code I had shown earlier were in the main implementation of MyComponent instead of being in the MyComponent (MyComponent) integration category.  Moving the necessary code in the proper place made it work as expected!  My custom component can now show up images at design time as well as at run time!  I hope this thread can help more people with the same problem in the future :)


Thanks for your valuable support


-Dalzhim
 _______________________________________________
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

  • Follow-Ups:
    • Re: Custom component fails to load images by name in a IBPlugin
      • From: "Dalzhim Dalzhim" <email@hidden>
References: 
 >Custom component fails to load images by name in a IBPlugin (From: "Dalzhim Dalzhim" <email@hidden>)
 >Re: Custom component fails to load images by name in a IBPlugin (From: Chris Hanson <email@hidden>)
 >Re: Custom component fails to load images by name in a IBPlugin (From: "Dalzhim Dalzhim" <email@hidden>)
 >Re: Custom component fails to load images by name in a IBPlugin (From: Jonathan Hess <email@hidden>)
 >Re: Custom component fails to load images by name in a IBPlugin (From: "Dalzhim Dalzhim" <email@hidden>)
 >Re: Custom component fails to load images by name in a IBPlugin (From: "Dalzhim Dalzhim" <email@hidden>)
 >Re: Custom component fails to load images by name in a IBPlugin (From: Jonathan Hess <email@hidden>)
 >Re: Custom component fails to load images by name in a IBPlugin (From: "Dalzhim Dalzhim" <email@hidden>)
 >Re: Custom component fails to load images by name in a IBPlugin (From: Jonathan Hess <email@hidden>)

  • Prev by Date: Re: Custom component fails to load images by name in a IBPlugin
  • Next by Date: Re: Generating Profiling Code
  • Previous by thread: Re: Custom component fails to load images by name in a IBPlugin
  • Next by thread: Re: Custom component fails to load images by name in a IBPlugin
  • Index(es):
    • Date
    • Thread