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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:27:06+00:00 2026-06-06T20:27:06+00:00

I have this code that where I would normally use one line: if (tableView

  • 0

I have this code that where I would normally use one line:

    if (tableView == self.searchDisplayController.searchResultsTableView)
{
    NSLog(@"Configuring cell to show search results");
    shoppingList = [self.searchResults objectAtIndex:indexPath.row];

    cell.textLabel.text = shopList.name; 
    cell.textLabel.text = shopList.type;
    cell.textLabel.text = shopList.price;
    cell.textLabel.text = shopList.occasion;


    } 

The reason I have this is that I am implementing a scope under my search bar.
Now the scope works, when I type in a name I would expect to see the name when I select the first scope which is the name of the product.

What is happening however is that it shows what is under occasion, since it is the last one in the list (I pressume). So when I type in the name of a product it comes up with the matching occasion instead of the name of the product.

How do I set it up that it shows what I select in the scope?

I have implemented the following method, to make the scope work correctly, just the labels are not coming up right, which is affected in the tableView section code above.

- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
 {

Any help is great:-)
Thanks.

  • 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-06T20:27:08+00:00Added an answer on June 6, 2026 at 8:27 pm

    The = operator is the assignment operator. That means that whatever is on the left side of the = operator is going to become whatever is on the right side after that line of code is executed.

    For example:

    int i = 5;
    i = 4;
    i = 3;
    i = 8;

    After all four of those lines are executed, i is equal to 8. It doesn’t matter that it was another value previously–the = operator obliterates whatever was in the variable before and places the new value into it.

    So, regardless of what you want your code to do, what you are doing is obliterating the value of cell.textlabel.text every time you use the = operator. shopList.name, shopList.type, and shopList.price don’t exist anymore after you set cell.textlabel.text to shopList.occasion, for the same reason i = 8 in my above example. This is a fundamental and hugely important programming concept.

    Do you understand what’s wrong, now? If you want to save all four items–price, name, type, and occasion–you need four separate variables to do so.


    As an aside, I’m fairly certain you aren’t using the word scope properly (unless I’m entirely misunderstanding the purpose of your program). From Wikipedia:

    In computer programming, a scope is the context within a computer
    program in which a variable name or other identifier is valid and can
    be used, or within which a declaration has effect. Outside of the
    scope of a variable name, the variable’s value may still be stored,
    and may even be accessible in some way, but the name does not refer to
    it; that is, the name is not bound to the variable’s storage.

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

Sidebar

Related Questions

I have this source code from 2001 that I would like to compile. It
I have trouble finding way to correctly refactor this code so that there would
I came across this code on reddit . I would have thought that type
I have this code that has one button that let's me choose an entry
I have this code that works in a unit test but doesn't work when
I have this code that I want to make point-free; (\k t -> chr
I have this code that fetches some text from a page using BeautifulSoup soup=
I have this code that changes the opacity of the div on hover. $(#navigationcontainer).fadeTo(slow,0.6);
I have this code that saves a pdf file. FileStream fs = new FileStream(SaveLocation,
i have this code that will check the array contains the specific string and

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.