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 7953193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:05:20+00:00 2026-06-04T03:05:20+00:00

The app needs to retrieve data from core-data then compare one of the values

  • 0

The app needs to retrieve data from core-data then compare one of the values with an IF STATEMENT

MyAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
        NSManagedObjectContext *context = [appDelegate managedObjectContext];


        NSEntityDescription *getDetails = [NSEntityDescription entityForName:@"Detail" inManagedObjectContext:context];
        NSFetchRequest *request = [[NSFetchRequest alloc] init];

        [request setEntity:getDetails];
        NSPredicate *pred = [NSPredicate predicateWithFormat:@"(genID = %i)", genID];
        [request setPredicate:pred];

        NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"genID" ascending:YES];
        [request setSortDescriptors:[NSArray arrayWithObject:sort]];


        NSError *error;
        NSArray *objects = [context executeFetchRequest:request error:&error];

        for (NSManagedObject *oneObject in objects) {   



            NSString *type = [oneObject valueForKey:@"type"];


            if (type == @"straight") {
                NSLog(@"straight");
                //straight logic removed
            }else if (type == @"Left") {
                NSLog(@"Left");
                //Left logic removed
            }else {
                NSLog(@"Else");
                //Else logic removed

            }


            }

The issue is that it never goes into “straight” or “left” always the ELSE. Stepping through the code I can see that values do match straight and left, even dumped them into a log file shows them fine. What is wrong?

  • 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-04T03:05:22+00:00Added an answer on June 4, 2026 at 3:05 am

    You need to compare strings using isEqual: or isEqualToString: or compare:.

    For instance:

    NSString *type = [oneObject valueForKey:@"type"];
    if ([type isEqualToString:@"straight"])
        // etc.
    

    Search StackOverflow for “NSString equal” or “NSString compare” if you need more explanation. You aren’t anywhere near the first person to ask this question, and you definitely won’t be the last.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an app that needs to retrieve some data from a server.
I'm building an android app who needs to present lots of data received from
I need to write on a TextView dynamically, actually my app retrieve data from
My app needs to display a graphical representation of a value ranging from -1
Because the data size isn't little that my web app needs to load, it
I have an app that needs to read a PDF file from the file
I'm building a Rails app that needs to connect to a custom TCP data
I'm working on my 2nd iPhone app and am curious about Core Data. Time
I'm stuck trying to retrieve data from an associated model store. Allow me to
I’m in the process of designing an iPhone app, using Core Data for data

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.