[Solved] Adding math symbols in a string [closed]

[ad_1]

int a = 10;
int b = 20;
NSString *c = @"+";

NSString *s = [NSString stringWithFormat:@"%d %@ %d", a, c, b];
NSExpression *e = [NSExpression expressionWithFormat:s];
int result = [[e expressionValueWithObject:nil context:nil] intValue];

NSLog(@"%d", result);

4

[ad_2]

solved Adding math symbols in a string [closed]