DDMathParser - Getting tokens

119 Views Asked by At

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

There are 1 best solutions below

0
On BEST ANSWER

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];