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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:28:42+00:00 2026-05-23T17:28:42+00:00

I’m trying to create a filter. I have a function that returns an NSArray

  • 0

I’m trying to create a filter. I have a function that returns an NSArray for the different categories I can have. I’d like one extra option for “All” to denote that no filter is being applied. For example, should display:

All
Soda
Wine
Beer

I started with this, but I don’t think it’s very good implementation at all, and it’s not correct either. It’s just where I’m at so far:

- (void)initCategoryDictionary {
    NSMutableArray *conditionCategories = (NSMutableArray *)[self GetAllCategories]; 
    [conditionCategories insertObject:@"All" atIndex:0];    // no filter case at first index
    NSMutableArray *objectValues = [NSMutableArray array];
    [objectValues addObject:[NSNumber numberWithBool:YES]]; // this is for the no filter case at the first index
    for (int i = 0; i < [conditionCategories count]; i++) {
        [objectValues addObject:[NSNumber numberWithBool:NO]];
    }
    self.CategoryDictionary = [NSMutableDictionary dictionaryWithObjects:objectValues forKeys:conditionCategories]; 
}

On the first line of the method, I don’t know if I should be typecasting this or not. My categories currently does not have an “All” category, so this is the way I could figure out to add “All” to the NSArray before inserting it into the dictionary.

I thought I could then add an array of YES, NO, NO, …. (NO for all the other items in the dictionary). This way, my dictionary would default to All being true (no filter applied). Then based on what is selected, I would change the All to NO, and the other values selected to YES and filter appropriately. (The for loop is wrong since it only gives me an array of 2 objects with 0 and 1 as my values.

So this is what I thought I would do, but obviously this isn’t a good or correct way to do things. Any thoughts? 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-05-23T17:28:42+00:00Added an answer on May 23, 2026 at 5:28 pm

    If All is either applied or not, why not just have it as a separate boolean value that you check as part of the filter, and don’t worry about it being in the array itself?

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

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am trying to loop through a bunch of documents I have to put
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I need a function that will clean a strings' special characters. I do NOT
I am trying to understand how to use SyndicationItem to display feed which is

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.