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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:19:44+00:00 2026-06-02T10:19:44+00:00

Im building an app where users will be able to filter through a set

  • 0

Im building an app where users will be able to filter through a set of photos based on 4 parameters:

model http://seismicdevelopment.com/shot.png

FeedType and PhotoType can be one of three possible values respectively. Market and Tag can contain multiple values that describe the photo. I have the ui setup where for FeedType/PhotoType is a series of UISwitches for each param. If you turn one value on, the others in that group will turn off.

Market/Tag have UIButtons that can be made selected/normal. Any selected button should be added to the filtering to narrow results.

I can’t seem to figure out how I should write the filtering logic to be most effective. Essentially on any control change, I need to rewrite the predicate filter but I can’t seem to wrap my head around how I can link the separate param filters together.

For Tag/Market I’d also like to add a disabled state for UIButtons that have no records, or no records based on the currently selected buttons.

  • 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-02T10:19:46+00:00Added an answer on June 2, 2026 at 10:19 am

    It is hard to tell a precise advice without knowing what kind the parameters are, but, as far as i can see, you need to have four variables,more likely,NSStrings, and every time the user changes the parameter, you create a new fetch predicate, by appending all that variables with the right format. That’s how i see it in general.

    UPDATE

    So, with Market and Tag Butons everything is quite obvious – you shoud use NSCompondPredicate. You’ll need an array of predicates, so make a property.

    @property (strong) NSMutableArray *subpredicates;
    

    Then, each time user touches the button, you add or remove that narrowing predicate.

    - (void)tagButtonTouched:(UIButton *)button
    {
        if (thisTagIsNotYetSelected)
            [subpredicates addObject:[NSPredicate predicateWithFormat:@"ANY tags.name == %@", button.titleLabel.text]];//or some other predicate based on that button title
        else
            [subpredicates removeObject:[NSPredicate predicateWithFormat:@"ANY tags.name == %@",button.titleLabel.text] ]];
    }
    

    Same thing for Markets

     - (void)marketButtonTouched:(UIButton *)button
     {
         if (thisMarketIsNotYetSelected)
             [subpredicates addObject:[NSPredicate predicateWithFormat:@"ANY markets.name == %@", button.titleLabel.text]];//or some other predicate based on that button title
         else
             [subpredicates removeObject:[NSPredicate predicateWithFormat:@"ANY markets.name == %@",button.titleLabel.text] ]];
     }
    

    You should also add two variables,i guess,NSPredicates or NSString,that will hold the value of selected FeedType and PhotoType,lets’s call them feedTypePredicate and photoTypePredicate respectivly. When user touches those switches(why not segmentedControls?), you just change their’s values.

    And, finally, you should just combine all those predicates into one and make your fetch!

    if(photoTypePredicate)
        [subpredicates addObject:photoTypePredicate];
    if(feedTypePredicate)
        [subpredicates addObject:feedTypePredicate];
    NSPredicate *finished = [NSCompoundPredicate andPredicateWithSubpredicates:subpredicates];//Your final predicate
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building an iOS app which users will be able to enter the
I am building an iPhone app in which users (or employees) will be able
i'm building an app that will display some newsletters to the users. the newsletters
I've building a very basic iphone app where the user will be able to
I'm building an app where I want to allow users to be able to
I'm building an app where my users will post content. The exact time of
I'm building an app which will aggregate events its users add to it. I'd
I am building a ios app for ipad, in which the user will be
I am building a ASP.NET MVC App that will allow a user to connect
I'm building an app that allows users to snap pictures using the iPhone camera,

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.