I'm pretty new in iOS dev. Basically I have a multidimensional array as per below
Array
(
[0] => Array
(
[Name] => Peter
[Gender] => Male
)
[1] => Array
(
[Name] => Glenn
[Gender] => Female
)
[2] => Array
(
[Name] => Richard
[Gender] => Male
)
)
At some point, I am going to add in additional key/value at certain index. Take for example, I am adding a new entry at index 1 at the end of the array(the sequence is not something to bother actually, it can fit in front or at the end) with [Location] => Japan
As such, the array should looks like this:
Array
(
[0] => Array
(
[Name] => Peter
[Gender] => Male
)
[1] => Array
(
[Name] => Glenn
[Gender] => Female
[Location] => Japan
)
[2] => Array
(
[Name] => Richard
[Gender] => Male
)
)
How can I achieve that? Pls inspect my code below as I really have no idea as every attempt results in EXC_BAD_ACCESS or app being terminated. Thanks in advance, Jason.
for(int x=0; x<[arrayVisitor count]; x++)
{
if ([[[arrayVisitor objectAtIndex:x]objectForKey:(@"Gender")]isEqual:@"Female"])
[[arrayVisitor objectAtIndex:x] addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys: @"Location",@"Japan",nil]];
}