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".