运维开发网

objective-C语言 从Path创建TFENode

运维开发网 https://www.qedev.com 2020-03-16 14:05 出处:网络 作者:运维开发网整理
如何从Path创建TFENode? 编辑: 我有点儿,TGlobalWindowController中有一个方法: struct TString { struct TRef<const __CFString *, TRetainReleasePolicy<CFStringRef>> fString; }; ... + (struct TFENode)nodeForUrl:(const
如何从Path创建TFENode?

编辑:

我有点儿,TGlobalWindowController中有一个方法:

struct TString {
    struct TRef<const __CFString *, TRetainReleasePolicy<CFStringRef>> fString;
};

...

+ (struct TFENode)nodeForUrl:(const struct TString *)arg1;

不幸的是,我无法创建TString.

EDIT2:

经过研究,我发现这种方法有效:

struct TString {
//struct TRef<CFStringRef, TRetainReleasePolicy<CFStringRef>> fString;
CFStringRef fString;
};

NSString *path = [[NSString alloc] initWithString:@"file:///"];
struct TString *tstr = (struct TString *)malloc(sizeof(struct TString*));
tstr->fString = (CFStringRef)path;
id node = [NSClassFromString(@"TGlobalWindowController") performSelector:NSSelectorFromString(@"nodeForUrl:") withObject:(id)tstr];
free(tstr);
[path release];

节点是正确的,但是一旦下一个垃圾收集过程开始,查找程序就会崩溃.

找到答案:

+ (char*) nodeForPath:(NSURL*)url node:(char*) node
{
    memset(node, 0, 0x204);

    int *v6;
    void* v7;

    if ( (double)NSAppKitVersionNumber < 1110.0 )
    {
        v6 = (int *)[url absoluteString];
    }
    else
    {
        v7 = [url absoluteString];
        v6 = (int *)&v7;
    }
    objc_msgSend_stret((id)node,NSClassFromString(@"TGlobalWindowController"), NSSelectorFromString(@"nodeForUrl:"), v6);
    return node;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消