0

我正在iOS使用在应用程序中创建树CFTree。我收到错误“使用未声明的标识符' CFTree'”。我错过了什么?我的代码:

#import "ViewController.h"
#import <CoreFoundation/CoreFoundation.h>

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    CFTree tree = CreateMyTree(kCFAllocatorDefault);
}

static CFTreeRef CreateMyTree(CFAllocatorRef allocator) {
    NSString *info = @"Bhushan is great";
    CFTreeContext ctx;
    ctx.version = 0;
    ctx.info = (__bridge void *)(info);
    ctx.retain = CFRetain;
    ctx.release = CFRelease;
    ctx.copyDescription = NULL;
    return CFTreeCreate(allocator, &ctx);
}
4

2 回答 2

0

类型是CFTreeRef,不是CFTree

CFTreeRef tree = CreateMyTree(kCFAllocatorDefault);
于 2013-10-23T11:45:38.807 回答
0

尝试这个:

NSString *info;
CFTreeContext ctx;

NSString *treeString = [[NSString alloc] initWithFormat:@"the tree string"];
info = treeString;

ctx.info = (__bridge void *)(info);
CFTreeRef myTree = CFTreeCreate(NULL, &ctx);

这是链接:在Objective C中创建一个CFTree

于 2013-10-23T11:53:25.013 回答