问题
I'm looking to get tokens back from a string (to aid in editing) and referring to the answer here iOS DDMathParser Get Number 'Blocks' it appears that this functionality may be deprecated. What is the most up-to-date way to get token objects from my string?
回答1:
Ok. So, this appears to be the current way of getting tokens from a string:
NSError *error = nil;
DDMathOperatorSet *opSet = [DDMathOperatorSet defaultOperatorSet];
DDMathStringTokenizer *tokenizer = [[DDMathStringTokenizer alloc] initWithString:@"123+142-3/51815*(-5+2.0)" operatorSet:opSet error:&error];
NSArray *tokens = [tokenizer allObjects];
来源:https://stackoverflow.com/questions/30741923/ddmathparser-getting-tokens