I’m new to Objective C, and I’m trying to call a method on an array (NSArray) of objects directly like this:
[[myPeople objectAtIndex: 0] setName: @"Shane"];
But this doesn’t seem to work, and returns a warning saying “Multiple methods named ‘setName’ found”
I can successfully perform the operation in this manner:
Person* person = [myPeople objectAtIndex: 0];
[person setName: @"Shane"];
Is my syntax simply incorrect in the first case, or should the second piece of code be used? Or is there a better way that I’m not aware of?
Thanks, any help is greatly appreciated
You can do it to all objects in the array like this:
[myPeople makeObjectsPerformSelector:@selector(setName:) withObject:@"Shane"];