we do have a calculator app in ios5 and we want the users to set their own values to our calculators variable buttons such as "x" or "y". For example the user set "x=5" and wants to do the calculation of" x + 5 = " the result should be 10 anyway.how do we make the program store the temporary values of variable defined by user in an NSMutableDictionary
Asked
Active
Viewed 1,953 times
2
-
Check out NSExpression, it may work better than what you are proposing... – Richard J. Ross III Jan 16 '12 at 00:39
1 Answers
8
Create the NSMutableDictionary
, convert the number to an NSNumber
and put it into the NSMutableDictionary
.
NSMutableDictionary *customValues = [NSMutableDictionary dictionary];
float value = 5;
NSNumber *number = [NSNumber numberForFloat:value];
[customValues setObject:number forKey:@"x"];
or using literals replace the above two lines with:
customValues[@"x"] = @(value);
Or are you asking a different question?

zaph
- 111,848
- 21
- 189
- 228