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