ios - Filter array objects by have a property or not in Objective-C -


i have array, objects has property "settings".

i want objects doesn't contains settings.settinga.

are there anyway without using loop?

edit:

i have array of profile objects. profile object has many properties, 1 of them is:

@property (nonatomic) profilesettings *settings; 

profilesettings object has property:

@property (nonatomic) nsstring *settinga; @property (nonatomic) nsstring *settingb; @property (nonatomic) nsstring *settingc; 

each profile can has profilesettings (not all) settings.

are there anyway without using loop?

yes.

your statement suggests know how test individual object determine whether wish include or exclude it, not wish write test in loop. so:

  1. use filterarrayusingpredicate: process array whole;
  2. use predicatewithblock: create predicate block; and
  3. write logic test object in block. block passed object array , must return bool indicating whether keep include (yes) or not in result.

hth


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -