开发者

Create a CFTree in Objective C

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜