OK. I've spent a ridiculous amount of time on this. I've looked all around on the internet to the point of feeling pretty stupid. I have program which is an array of x, 2, "+". So I make a copy of program and try to replace x with its value (5) from variableValues.
Can anyone tell me how in the world to do this?
+ (double)runProgram:(id)program usingVaraiableValues:(NSDictionary *)variableValues {
NSMutableArray *program2 = program;
for (NSString *obj in program) {
NSNumber *number = [variableValues objectForKey:obj];
if (number) {
int index = [program indexOfObject:obj];
NSLog(@"index = %i", index);
[program2 replaceObjectAtIndex:index withObject:number];
}
}
return [self runProgram:program2];
}
program2 = programdoesn't make a copy, much less a mutable one.