You can use NSExpression for this:
NSExpression *expression = [NSExpression expressionWithFormat:@"1+2"];
NSLog(@"%@", [expression expressionValueWithObject:nil context:nil]);
For further information read the documentation of the used methods.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…