开发者

Create a CFTree in Objective C

开发者 https://www.devze.com 2023-02-13 00:16 出处:网络
I want to create a basic CFTree with some string info in Objective-C. This is my code //CFtree attempt NSString *info;

I want to create a basic CFTree with some string info in Objective-C.

This is my code

//CFtree attempt
NSString *info;
CFTreeContext ctx;

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

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

I g开发者_如何学Cet an "EXC_BAD_ACESS" error on the last line. Can someone please tell me how to configure this properly.


It seems that ctx should be initialized.

ctx.version = 0;
ctx.info = info;
ctx.retain = CFRetain;
ctx.release = CFRelease;
ctx.copyDescription = CFCopyDescription;


You may want to initialize the ctx struct to 0 before using it since there are members in it that otherwise may cause erratic behavior as the CFTreeCreate thinks they are pointing to something relevant.

see

0

精彩评论

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

关注公众号