The type is CFTreeRef
, not CFTree
:
CFTreeRef tree = CreateMyTree(kCFAllocatorDefault);
Question
I am creating tree in iOS
application using CFTree
. I am getting error "Use of undeclared identifier 'CFTree
'". What I am missing?
My code :
#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);
}
Solution
The type is CFTreeRef
, not CFTree
:
CFTreeRef tree = CreateMyTree(kCFAllocatorDefault);
OTHER TIPS
Try this:
NSString *info;
CFTreeContext ctx;
NSString *treeString = [[NSString alloc] initWithFormat:@"the tree string"];
info = treeString;
ctx.info = (__bridge void *)(info);
CFTreeRef myTree = CFTreeCreate(NULL, &ctx);
this is the link:Create a CFTree in Objective C