我正在尝试为Finder创建一个SIMBL插件,以便在一些文件上添加图标覆盖。
我有这样的代码:
@implementation NSObject (FAIconOverlay)
- (void)FAIconOverlay_TIconAndTextCell_drawIconWithFrame:(struct CGRect)arg1
{
[self FAIconOverlay_TIconAndTextCell_drawIconWithFrame:arg1];
if (![self respondsToSelector:@selector(node)]) {
return;
}
NSLog(@"%@", [[[NSClassFromString(@"FINode") nodeWithFENode:[(TNodeIconAndNameCell *)self node]] fullPath] lastPathComponent]);
// Draw the icon overlay
}
- (void)FAIconOverlay_TDesktopIcon_drawIconInContext:(struct CGContext *)arg1
{
[self FAIconOverlay_TDesktopIcon_drawIconInContext:arg1];
}
@end我可以绘制图标覆盖,但是,当我尝试获取文件的路径时,我得到一个“使用未声明的标识符TNodeIconAndNameCell”。查看这个链接< How to Write OS X Finder plugin >,我发现这是生成Finder.h文件所必需的。
我的问题是:如何生成此文件??我试着运行"class-dump -H Finder.app“,但是我得到了太多的编译错误
非常感谢!
发布于 2012-07-06 02:45:08
解决方案是不包含类转储生成的所有标头(现在如何生成这些标头,请查看@jackjr300的答案)。只需要包含已使用的头文件,并修复编译问题。
发布于 2012-05-26 10:22:28
创建"Finder.h“:
sudo class-dump -H -o /output_directory/Path /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder发布于 2012-05-26 07:01:59
您应该覆盖TNodeIconAndNameCell的drawIconWithFrame:方法,而不是覆盖TIconAndTextCell的drawIconWithFrame:方法。
Class finder_class = [objc_getClass("TNodeIconAndNameCell") class];
class_addMethod(finder_class, @selector(FT_drawIconWithFrame:),
class_getMethodImplementation(self_class, @selector(FT_drawIconWithFrame:)),"v@:{CGRect={CGPoint=dd}{CGSize=dd}}");
old = class_getInstanceMethod(finder_class, @selector(drawIconWithFrame:));
new = class_getInstanceMethod(finder_class, @selector(FT_drawIconWithFrame:));
method_exchangeImplementations(old, new);然后你可以这样做:
NSLog(@"%@", [[[NSClassFromString(@"FINode") nodeWithFENode:[self node]] fullPath] lastPathComponent]);https://stackoverflow.com/questions/9761426
复制相似问题