i need to create and destroy dynamically dictionaries, or arrays,
and have them as instance variables,
so for example, [pseudocode]
*.h
nsmutableDictionary myDictn???
nsstring arrayn ???
how to create an instance dictionarie, and property, that dinamically get created and destroyed?, and how to refer to it?
*.m
n = 0
create container {
myDictn alloc init
n+1
}
other {
myDictn addobject@"data" forKey"myKey"
}
destroy container {
myDictn release
n-1
}
So what intend to show is that i would like to have myDict1, myDict2…
if created,
or destroy them if needed
thanks a lot!
I think what you’re asking for is how to have multiple mutable dictionaries dynamically created. You haven’t said where the numbering scheme is coming from, so you may need to modify this solution for your purposes.
What you want is an array or dictionary of dictionaries.
Make one
NSMutableDictionarycalled something likedictionaryContainer. Then, when you want to create dictionary number 7, doTo recall that dictionary, do
You don’t have to hard code the 7, you can get it from anywhere and pass it in as an integer variable.