2012-03-18 50 views
1

我正在尝试为Finder创建一个SIMBL插件,以便在某些文件上添加图标叠加层。为SIMBL插件生成“Finder.h”

我有这样的代码:

@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”,但是编译错误太多

非常感谢!

回答

0

的溶液并不包括由类产生的所有头转储(到现在如何生成这个标题检查@ jackjr300答案)。只需要包含已使用的标题并修复编译问题。

1

而不是重写TIconAndTextCell的drawIconWithFrame:方法,您应该重写TNodeIconAndNameCell的drawIconWithFrame:方法。

Class finder_class = [objc_getClass("TNodeIconAndNameCell") class]; 

class_addMethod(finder_class, @selector(FT_drawIconWithFrame:), 
       class_getMethodImplementation(self_class, @selector(FT_drawIconWithFrame:)),"[email protected]:{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]); 
4

要创建一个 “Finder.h”:

sudo class-dump -H -o /output_directory/Path /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder