I'm smashing my head with a NSDictionary
and NSArray
add objects for keys stuff.
I got 2 mutable arrays and I want to combine them.
NSMutableArray 1 :
{
email = "[email protected]";
"password" = "2017-05-23 13:08:03";
}
NSMutableArray 2
(
{
"created_at" = "2017-06-22 00:00:00";
"id_weather_city" = 1;
name = Cityname;
"updated_at" = "2017-06-22 00:00:00";
},
{
"created_at" = "2017-06-22 00:00:00";
"id_weather_city" = 2;
name = Cityname2;
"updated_at" = "2017-06-22 00:00:00";
}
)
I want to combine them together like this, but I don't know how right array :
{
email = "[email protected]";
"password" = "2017-05-23 13:08:03";
"weather":(
{
"created_at" = "2017-06-22 00:00:00";
"id_weather_city" = 1;
name = Cityname;
"updated_at" = "2017-06-22 00:00:00";
},
{
"created_at" = "2017-06-22 00:00:00";
"id_weather_city" = 2;
name = Cityname2;
"updated_at" = "2017-06-22 00:00:00";
}
)
}
The first one isn't an array, it's a dictionary. Knowing that you can do
NSMutableDictionary *dict = [item1 mutableCopy];
dict[@"weather"] = [item2 copy];
Simply copy the first dictionary, and insert the second one for weather
key