I don’t understand why it can’t add element to my dictionary. In my console, i always get the “It’s not here!” I have posted my code below
//.m
#import "ExercisesViewController.h"
#import "STATableViewController.h"
@implementation ExercisesViewController
@synthesize descriptionLabel = _descriptionLabel;
@synthesize descriptionsDictionary = _descriptionsDictionary;
@synthesize objName = _objName;
- (void)viewDidLoad
{
[super viewDidLoad];
_descriptionsDictionary = [[NSMutableDictionary alloc]init];
[_descriptionsDictionary setObject:@"foo" forKey:@"bar"];
if([[_descriptionsDictionary allKeys] containsObject:@"foo"])
NSLog(@"It's here!");
else
NSLog(@"It's not here!");
}
You are adding the value
foofor the keybarbut then checking the keys forfoo. Reverse the key/value you are adding: