DDMathParser - Getting tokens

2019-08-30 23:10发布

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条回答
闹够了就滚
2楼-- · 2019-08-30 23:37

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];
查看更多
登录 后发表回答