Note that there are some explanatory texts on larger screens.

plurals
  1. POUse NSPredicate for matching id's in two arrays
    primarykey
    data
    text
    <p>Hello i have a maybe easy question but i cant handle it yet.</p> <ul> <li>I have a Modelclass 'Location' which holds an Array with Category ID's (12, 23, 56).</li> <li>Then i have an Array with all available Category ID's (1,2,3,4,5,6,7,...)</li> <li>All this Categories have an ID are shown in a TableView and are able to select or not.</li> <li>I show a punch of Markers on a MapView (Annotation Class is Location) which should be shown based on the selection of the filters in the mentioned Filter TableView.</li> </ul> <p>I need to implement a "Filter by Category" function which removes all markers and add them again but just based on the selection in the list.</p> <p>So i need to compare the array with the filter-id's in the Location Model with the Array with all the Filter-ID's in the TableView. i used the following function for this:</p> <pre><code>for (Location *currLocation in arrListOfLocationsNearby) { </code></pre> <p>for (NSString *currKatId in currLocation.arrKatIds) {</p> <pre><code>NSInteger intCurrKatId = [currKatId integerValue]; NSLog(@"Current KatId %@ id: %d \n", currLocation.strAdr, intCurrKatId); for (Filter *currFilter in [SDM getSharedDataManager].arrListOfFilterOptions) { if (currFilter.isSelected) { NSInteger intCurrFilterId = [currFilter.strAtt_id intValue]; NSLog(@"Current Filter %@ id: %d \n", currFilter.strAtt_text, intCurrFilterId); if ([currKatId intValue] == [currFilter.strAtt_id intValue]) { currLocation.isVisible = YES; }else { currLocation.isVisible = NO; } } } </code></pre> <p>} }</p> <p>I know this will be the most ineffective way to loop through everything. I want to use somehow NSPredicate for this but i never used them before and i can't find examples for my problem.</p> <p>Any Hints from you guys?</p> <p>regards m.</p>
    singulars
    1. This table or related slice is empty.
    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