How to store the given below into NSDictionary
{
"Test":"Example"
}
How to store the given below into NSDictionary
{
"Test":"Example"
}
You can add value for key by using this
NSDictionary *dictionary=[NSDictionary dictionaryWithObjectsAndKeys:@"Test",@"Example", nil];
You can add value for key by using 'initWithObjects:(objects) forKeys:'
NSDictionary* dictionary = [[NSDictionary alloc] initWithObjects:@[@"Example",@"Example2"] forKeys:@[@"Test",@"Test2"]];
NSLog(@"%@",dictionary);
//{
// Test = Example;
// Test2 = Example2;
//}
Or you can use NSMutableDictionary :
NSMutableDictionary *mutableDictionary = [[NSMutableDictionary alloc] init];
[mutableDictionary setObject:@"Example" forKey:@"Test"];
[mutableDictionary setObject:@"Example2" forKey:@"Test2"];
NSLog(@"%@",mutableDictionary);
//{
// Test = Example;
// Test2 = Example2;
//}
Same output for these. Also you should take a look