Iphone 在目标C中创建CFTree
我想用Objective-C中的一些字符串信息创建一个基本CFTree 这是我的密码Iphone 在目标C中创建CFTree,iphone,objective-c,data-structures,tree,binary-tree,Iphone,Objective C,Data Structures,Tree,Binary Tree,我想用Objective-C中的一些字符串信息创建一个基本CFTree 这是我的密码 //CFtree attempt NSString *info; CFTreeContext ctx; NSString *treeString = [[NSString alloc] initWithFormat:@"the tree string"]; info = treeString; ctx.info = info; CFTreeRef myTree = CFTreeCreate(NULL, &a
//CFtree attempt
NSString *info;
CFTreeContext ctx;
NSString *treeString = [[NSString alloc] initWithFormat:@"the tree string"];
info = treeString;
ctx.info = info;
CFTreeRef myTree = CFTreeCreate(NULL, &ctx);
我在最后一行出现“EXC_BAD_access”错误。
有人能告诉我如何正确配置它吗。您可能希望在使用它之前将ctx结构初始化为0,因为其中有成员,否则可能会导致不稳定的行为,因为CFTreeCreate认为它们指向相关的东西
似乎应该初始化ctx
ctx.version = 0;
ctx.info = info;
ctx.retain = CFRetain;
ctx.release = CFRelease;
ctx.copyDescription = CFCopyDescription;