我使用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);
}
答案 0 :(得分:0)
类型为CFTreeRef
,而不是CFTree
:
CFTreeRef tree = CreateMyTree(kCFAllocatorDefault);
答案 1 :(得分: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);