iphone - Basic Expression Language Within iOS -


i looking create basic expression language can leverage within ios application. pulling these values in file @ runtime. in past have leveraged regular expressions this, has own limitations (as have 2 operands , operator). want have bit more robust support expressions following:

some examples:

valuea != valueb (valuea == valueb) && (valuec != valued) valuea >= valueb 

basically, want provide dictionary expression evaluator , have pull values variables dictionary.

any thoughts on efficient way done? i've done 5 minutes of research morning on coreparse , parsekit, new both (and parser generators whole).

you use nspredicate, example:

nsstring *expr = @"($valuea == $valueb) && ($valuec != $valued)"; nspredicate *predicate = [nspredicate predicatewithformat:expr]; nsdictionary *vars = @{@"valuea": @7, @"valueb" : @7, @"valuec": @3, @"valued": @4}; bool result = [predicate evaluatewithobject:nil substitutionvariables:vars]; 

note variables have start $ in predicate string.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -