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:
- use
filterarrayusingpredicate:
process array whole; - use
predicatewithblock:
create predicate block; and - write logic test object in block. block passed object array , must return
bool
indicating whether keep include (yes
) or not in result.
hth
Comments
Post a Comment