nsmutablearray * arrayname = [nsmutablearrayarray];
nsmutablearray * array = [nsmutablearrayarray];
[Array removeallobjects];
for (int i =0; i< ; i++) {
nsstring * str = [nsstringstringwithformat:@ "name%i", I];
[Arraynameaddobject: str];
}
// Way one In for in-loop initialization dictionary dict 10
for (int i =0; i< ; i++) {
nsmutabledictionary * dict = [nsmutabledictionarydictionary];
nsstring * value = [nsstringstringwithformat:@ "female%04i. JPG ", I];
nsstring * key = Arrayname[i];
[Dictsetobject: Value forkey: key];
[Arrayaddobject:d ICT];
}
NSLog(@ "%@*************", array);
// mode two initializes the dictionary dictoutside of the for loop, and then initializes the mutable dictionary outside of the loop, adding a key-value pair within the dictionary each time the loop is added, Assigns a dictionary of 10 key-value pairs to an array
nsmutablearray * array2 = [nsmutablearrayarray];
nsmutabledictionary * dict2 = [nsmutabledictionarydictionary];
for (int i =0; i< ; i++) {
nsstring * value = [nsstringstringwithformat:@ "female%04i. JPG ", I];
nsstring * key = Arrayname[i];
[Dict2setobject: Value forkey: key];
}
[Array2addobject:d Ict2];
NSLog (@ "%@____________", array2);
// The difference between the two can be clearly seen from the printed results
// because the dictionary is not understood very deeply: just think of him as a key-value pair, but he can actually save n Key pairs (if you initialize a mutable dictionary every time before setting a key-value pair for a mutable dictionary, there is only one key-value pair for each dictionary)
What is the difference between initializing the nsmutabledictionary in the loop and initializing the nsmutabledictionary outside of the loop, given the two ways iOS gives Nsmutabledictionary a loop assignment? What is the difference between initializing the nsmutabledictionary in the loop and initializing the nsmutabledictionary outside of the loop when iOS gives Nsmutabledictionary a loop assignment? (Resolved)
What is the difference between initializing the nsmutabledictionary in the loop and initializing the nsmutabledictionary outside of the loop, given the two ways iOS gives Nsmutabledictionary a loop assignment? (Resolved)