Note that there are some explanatory texts on larger screens.

plurals
  1. POSet up a NSMutableArray of objects to match a string value
    primarykey
    data
    text
    <p>I'm using the value of two sliders as the first search criteria.</p> <hr> <p>Now I want a second criteria. I have a </p> <pre><code>NSMutableArray *suitsArray; </code></pre> <p>which is containing up to 10 words, or it could be empty (0 words). Example of array:</p> <pre><code>2012-08-12 03:13:14.825 App[4595:f803] The content of array is( mushroom, grill, pizza ) </code></pre> <hr> <p>What I want is this:</p> <p>If suitsArray is like above, containing words <strong>mushroom</strong>, <strong>grill</strong> and <strong>pizza</strong></p> <p>and the "Suits" value in a dictionary is: "This wine suits <strong>mushroom</strong> dishes, <strong>grilled</strong> food, <strong>pizza</strong> and chicken." </p> <p>This dictionary is added to searchResultsArray, same with all other dictionaries where "Suits" value containing words <strong>mushroom</strong>, <strong>grill</strong> and <strong>pizza</strong>.</p> <p>But if suitsArray is empty of objects, skip this critera.</p> <p>But I'm not sure how to write the code for it. Can you help me on it?</p> <hr> <pre><code>-(IBAction)searchButtonPressed:(id)sender{ resultObjectsArray = [NSMutableArray array]; for(NSDictionary *object in allObjectsArray) { NSString *objectPrice = [object objectForKey:@"75 cl price"]; NSString *suitsString = // the words in suitsArray NSString *objectSuits = [object objectForKey:@"Suits"]; BOOL priceConditionGood = YES; if (minPrisSlider.value &lt;= maxPrisSlider.value &amp;&amp; (winePrice.floatValue &lt; minPrisSlider.value || winePrice.floatValue &gt; maxPrisSlider.value)) priceConditionGood = NO; if (priceConditionGood) [resultObjectsArray addObject:object]; } ResultsTableViewController *nextController = [[self storyboard] instantiateViewControllerWithIdentifier:@"ResultsController"]; nextController.objectsArray = [[NSMutableArray alloc]initWithArray:resultObjectsArray]; [self.navigationController pushViewController:nextController animated:YES]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload