Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8077043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:23:36+00:00 2026-06-05T15:23:36+00:00

I have a NSString object having multiple conditions specified in it like below: NSString

  • 0

I have a NSString object having multiple conditions specified in it like below:

NSString *strFormula1 = @"\"man\" == \"man\" && 1<5 || 12<9";
NSString *strFormula2 = @"\"pac@pac.com\" == \"pac1@pac1.com\" || 9==9 && 8>2 || 2==2";

I want to execute formula specified in the NSString object & find out the answer as BOOL.
Whether the condition specified is returning True or False.

Thanks in advance:)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T15:23:37+00:00Added an answer on June 5, 2026 at 3:23 pm

    Just use an NSPredicate like this:

    NSString *strFormula1 = @"\"man\" == \"man\" && 1<5 || 12<9";
    NSString *strFormula2 = @"\"pac@pac.com\" == \"pac1@pac1.com\" || 9==9 && 8>2 || 2==2";
    NSString *strFormula3 = @"\"hello\" == \"world\"";
    
    NSPredicate *predicate = [NSPredicate predicateWithFormat:strFormula1];
    BOOL result = [predicate evaluateWithObject:nil]; //True
    
    predicate = [NSPredicate predicateWithFormat:strFormula2];
    result = [predicate evaluateWithObject:nil]; //True
    
    predicate = [NSPredicate predicateWithFormat:strFormula3];
    result = [predicate evaluateWithObject:nil]; //False
    

    And if you’re curious to see how the predicate parsed your expression just use:

    NSLog(@"%@", [predicate predicateFormat]);
    

    Which in our case returns:

    ("man" == "man" AND 1 < 5) OR 12 < 9 //1st Expression
    "pac@pac.com" == "pac1@pac1.com" OR (9 == 9 AND 8 > 2) OR 2 == 2 //2nd Expression
    "hello" == "world" //3rd Expression
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an events object which is given below NSString *name; NSString *date; NSInteger
I have to use scanf() for accepting name of user in NSString object. If
I have a NSArrayController with following Object: @interface AdressCard : NSObject <NSCoding> { NSString*
I have NSString like My name is. I want to remove text after coming
I have an NSString that I'd like to append a { at the beginning
Let us say we have some code that looks like below: @interface SomeClass :
I'm having an issue with the UITableView object updating after load. I have a
In my objective-c project, I have a protocol like this: @protocol MyProtocol -(id) get:(NSString
I have a NSString object and want to change it into unichar. int decimal
i have an NSArray which contains custom objects, the objects have an NSString property,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.