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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:39:39+00:00 2026-06-12T18:39:39+00:00

I am getting this error when I analize my ios project The left operand

  • 0

I am getting this error when I analize my ios project

The left operand of '==' is a garbage value

this is what the code looks like where its occurring.. This method is used to sort the array I have that is returned to me from the DB.

- (NSMutableArray *)startSortingTheArray:(NSMutableArray *)unsortedArray
{
    [unsortedArray sortUsingComparator:^ NSComparisonResult(SearchResultItem *d1, SearchResultItem *d2) {
        //initalize comparison
        NSComparisonResult result;

        NSInteger manufacturerID1 = d1.manufacturerID;
        NSInteger manufacturerID2 = d2.manufacturerID;
            if (manufacturerID1 > manufacturerID2)
                return NSOrderedAscending;
            if (manufacturerID1 < manufacturerID2)
                return NSOrderedDescending;
            if (manufacturerID1 == manufacturerID2) {

            NSString *model1 = d1.model;
            NSString *model2 = d2.model;
            result = [model1 localizedCompare:model2];
        }
        if (result == NSOrderedSame) {
//..
  • 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-12T18:39:40+00:00Added an answer on June 12, 2026 at 6:39 pm

    The compiler is complaining because it believes it’s possible to reach the == comparison before result has a value.

    The best option given your code is to use else if and else:

    if (manufacturerID1 > manufacturerID2)
        return NSOrderedAscending; // we won't reach the comparison so result doesn't matter
    else if (manufacturerID1 < manufacturerID2)
        return NSOrderedDescending; // we won't reach the comparison so result doesn't matter
    else {
        NSString *model1 = d1.model;
        NSString *model2 = d2.model;
        result = [model1 localizedCompare:model2]; // in any other case, result will be set.
    }
    ...
    

    Or you could do this:

    NSComparisonResult result;
    ...
    if (manufacturerID1 > manufacturerID2)
        return NSOrderedAscending;
    else if (manufacturerID1 < manufacturerID2)
        return NSOrderedDescending;
    
    NSString *model1 = d1.model;
    NSString *model2 = d2.model;
    result = [model1 localizedCompare:model2];
    ...
    

    Or even this:

    if (manufacturerID1 > manufacturerID2)
        return NSOrderedAscending;
    else if (manufacturerID1 < manufacturerID2)
        return NSOrderedDescending;
    
    NSComparisonResult result = [d1.model localizedCompare:d2.model];
    ...
    

    This way the compiler knows that if the comparison is reached, the value of result will already have been set.

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

Sidebar

Related Questions

Am getting this error for my code: Undefined symbols for architecture x86_64: _spendDollars, referenced
Getting this error when I follow the simple code example from jsoncpp, that basically
im getting this error but I have no idea why its happening. It stops
Getting this error building a C++ project in VS2008. Very confused what it means,
Getting this error while compiling C++ code: undefined reference to `__stack_chk_fail' Options already tried:
Getting this error with my fetch's predicate 2011-08-13 13:49:12.405 Codes[16957:10d03] NSlog Array: code BETWEEN
Getting this error while trying to compile a copied code from a Fortran 77
Am getting this error message for the following code, but it doesn't make sense
Im getting this really annoying error in when I run this Haskell code. For
Getting this error: 2009-09-03 12:44:02.307 xcodebuild[307:10b] warning: compiler 'com.apple.compilers.llvm.clang.1_0.analyzer' is based on missing compiler

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.