Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 生成";Finder.h";对于SIMBL插件_Macos_Finder_Simbl - Fatal编程技术网

Macos 生成";Finder.h";对于SIMBL插件

Macos 生成";Finder.h";对于SIMBL插件,macos,finder,simbl,Macos,Finder,Simbl,我正在尝试为Finder创建一个SIMBL插件,在一些文件上添加图标覆盖 我有以下代码: @implementation NSObject (FAIconOverlay) - (void)FAIconOverlay_TIconAndTextCell_drawIconWithFrame:(struct CGRect)arg1 { [self FAIconOverlay_TIconAndTextCell_drawIconWithFrame:arg1]; if (![self re

我正在尝试为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”。查看此链接<>我发现生成Finder.h文件是必要的

我的问题是:如何生成此文件??我试着运行“class dump-H Finder.app”,但编译错误太多了


多谢各位

不应重写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:)),"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]);

您应该重写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]);
要创建“Finder.h”,请执行以下操作:

要创建“Finder.h”,请执行以下操作:


解决方案不包括类dump生成的所有头文件(要了解如何生成此头文件,请检查@jackjr300答案)。只需要包含已使用的头并修复编译问题。

解决方案不包括类转储生成的所有头(现在如何生成此头请查看@jackjr300答案)。只需要包含使用过的头并修复编译问题