1 warning, 2 errors page 141


#1

Hey guys,

I am stuck on page 141. It wants me to create a dictionary of executives.

It keeps returning with:

// Create a dictionary of executives
NSMutableArray *executives = [[NSMutableDictionary alloc] init];
WARNING : Incompatible pointer types initializing ‘NSMutableArray *_strong’ with an expression of type ‘NSMutableDictionary *’ :

// Is this the first employee?
if (i == 0) {
[executives setObject:person forKey:@“CEO”]; ERROR : No visible @interface for ‘NSMutableArray’ declares the selector ‘setObject:forKey:’ :
}

        // Is this the second employee?
        if (i == 1) {
            [executives setObject:person forKey:@"CTO"]; ERROR : No visible @interface for 'NSMutableArray' declares the selector 'setObject:forKey:' :

Please help, as it is hindering my learning process.

~Logan


#2

Also, I meant to post this in 21. Collection Classes.

Sorry about the confusion. :L

~Logan


#3

I don’t have this particular book but it looks to me like the problem is because you are declaring executives as an NSMutableArray but it should be an NSMutableDictionary. I.e:

NSMutableDictionary *executives = [[NSMutableDictionary alloc] init];


#4

Thank you so much, Mr. Serpent! I had wondered if that was the case, but never dug deeper :I Thank you, good sir! You have saved my coding career :stuck_out_tongue:

~Logan