Re: More on dictionaries
Re: More on dictionaries
- Subject: Re: More on dictionaries
- From: Dustin Voss <email@hidden>
- Date: Wed, 15 Oct 2003 17:44:55 -0700
On Tuesday, October 14, 2003, at 11:52 PM, April Gendill wrote:
I have a dictionary structure that is basically built from a
directory structure. I need to be able to search this dictionary as
deep as it goes (files are strings and directories are nested
dictionaries in this structure)
here's what information I have when I begin the search:
I know the root dictionary. Since the dictionary is a representation
of a directory structure you could think of it as /root/item/....
I know the key name for the item that must be move/deleted
It's pretty easy to find the item. I run a loop.
in the loop I have:
if([theDictionary objectForKey:theSearchItem]){
do something then leave the loop
}
The problem is the do something. I have to be able to remove the
object from the dictionary and I have no idea how. since the item to
remove can be many parent/children deep I don't know how to remove it
from the master dictionary..
I know that I'll need to return an id since I could either be dealing
with a string or dictionary.
I've been trying to pass it as [self removeObject:theObject
fromDict:masterDict]
the function is written as: -(id)removeObject:(id)theObject
fromDict:(NSMutableDictionary *)theDict
I used a mutable dictionary so I could edit it as I went, but thats
the problem... I'm not sure how to remove the item when I find it and
then put the master dictionary back together correctly.
I think you've heard this advice before, but consider using a CFTree.
It's not actually as hard as it may appear. See
<
http://www.cocoadev.com/?CFTree>.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.