Wednesday, 20 February 2013

To make NSdictionary containing objects with nested NSdictionary


NSMutableDictionary *dict = [NSMutableDictionary dictionary];
[dict setValue:@"1" forKey:@"image"];


NSMutableDictionary *gpsDict = [NSMutableDictionary dictionary];
     [gpsDict setValue:@"lat" forKey:@"lat"];
     [gpsDict setValue:@"long" forKey:@"long"];

[dict setObject:gpsDict forKey:@"gps_data"];


OUTPUT:

{"image":"1","gps_data":{"lat":"lat","long":"long"}}