首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为SIMBL插件生成"Finder.h“

为SIMBL插件生成"Finder.h“
EN

Stack Overflow用户
提问于 2012-03-19 03:15:39
回答 3查看 1.3K关注 0票数 1

我正在尝试为Finder创建一个SIMBL插件,以便在一些文件上添加图标覆盖。

我有这样的代码:

代码语言:javascript
复制
@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“,但是我得到了太多的编译错误

非常感谢!

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-07-06 02:45:08

解决方案是不包含类转储生成的所有标头(现在如何生成这些标头,请查看@jackjr300的答案)。只需要包含已使用的头文件,并修复编译问题。

票数 0
EN

Stack Overflow用户

发布于 2012-05-26 10:22:28

创建"Finder.h“:

代码语言:javascript
复制
sudo class-dump -H -o /output_directory/Path  /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder
票数 4
EN

Stack Overflow用户

发布于 2012-05-26 07:01:59

您应该覆盖TNodeIconAndNameCell的drawIconWithFrame:方法,而不是覆盖TIconAndTextCell的drawIconWithFrame:方法。

代码语言:javascript
复制
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);

然后你可以这样做:

代码语言:javascript
复制
NSLog(@"%@", [[[NSClassFromString(@"FINode") nodeWithFENode:[self node]] fullPath] lastPathComponent]);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9761426

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档