Anyone done an Objective-C Xode version of Osherove´s TDD Kata “String Calculator”?

前端 未结 2 872
别那么骄傲
别那么骄傲 2021-01-14 10:42

Always trying to code better and I am interested in doing TDD for Objective-C and Xcode.
Do you know any post that implement something like Roy Osherove´s \"String Calc

2条回答
  •  太阳男子
    2021-01-14 11:37

    I'd use NSPredicate like this:

    NSPredicate * parsed = [NSPredicate predicateWithFormat:@"6 * 7 = 0"];
    NSExpression * left = [(NSComparisonPredicate *)parsed leftExpression];
    NSNumber * result = [left expressionValueWithObject:nil context:nil];
    NSLog(@"result: %@", result);
    

    Look here for more info on using NSPredicate in weird ways.

提交回复
热议问题