Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CFTree vs. CFArray design question



It looks to me like CFTree would be conceptually more appropriate. The data values exist in the CFTreeContext structure that you supply to CFTreeCreate. In your case if looks like your values will all be CFURLs so I'll bet your CFTreeContext could be defined like this.

{
CFTreeContext treeContext;
CFTreeRef directoryTree;
CFURLRef oneFileURL;

treeContext.version = 0;
treeContext.info = oneFileURL; // important part!!
treeContext.retain = CFRetain;
treeContext.release = CFRelease;
treeContext.copyDescription = CFCopyDescription;

directoryTree = CFTreeCreate(kCFAllocatorDefault, &treeContext);
}

Then you'd like up that tree node with its parent and children nodes. Check out http://developer.apple.com/documentation/CoreFoundation/Conceptual/ CFCollections/Tasks/usingtrees.html#//apple_ref/doc/uid/20001137 for more details. I've never used CFTrees myself, it looks somewhat involved. Hope that helps!

Ian


I have a little conceptual type question about CF collections. I want to
use one to store a directory hierarchy. The the collection will contain
CFURLs to files, and then sub-collections that represent directories which
are filled with CFURLs to the files in those sub-directories, etc. I'm
not sure which collection type is most appropriate: CFTree or CFArray.

I will admit, I'm having a little trouble wrapping my head around all of
the nuances of CFTree and its purpose, so that's why I'm not sure. In a
way, it seems like it makes more sense because of its, ummm, tree-like
design. But in another sense, I don't really see how it holds data values
aside from just the nodes that represent its own structure. CFArray seems
more appropriate with respect to holding data values, but it seems like it
might be a little weird to have mixed types of values (CFURLs and
CFArrays), although I can just CFGetTypeID to figure out what each value
is. So anyway, I'm not sure, and I'm a little fuzzy on CFTrees. Are
CFTrees really just intended for XML data, or are they more general?

Thanks for any guidance,
Marc
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.