arrays - How to use NSPredicate with NSPredicateEditor on different data (Multiple Predicates?) -
i've got array of filepaths , i've got nspredicateeditor setup in ui user can combine nspredicate find file. should able filter name, type, size , date.
there several problems have now:
- i can only 1 predicate object editor. when use "predicateforrow:" returns (null)
- if user wants filter file name , size or date, can't use predicate on array anymore because information not contained in it
can split predicate different predicates without converting nsstring object, search every @" or " | @" , " , seperating components array , converting every nsstring new predicate?
in nspredicateeditor settings i've options "left expression": keypaths, constant values, strings, integer numbers, floating point numbers , dates. want display dropdown menu user "name", "type", "date", "size". generated predicate automatically looks this:
"name" matches[c] "nametest" or "type" matches[c] "jpg" or size == 100
because array filled strings, search "name", "type" etc. , strings not respond @"mystring"*.name*m filter returns 0 objects. there way show name, type, size , date in menu, write "self" predicate without doing hand?
i've searched in official apple tutorials, on stackoverflow, google, , youtube find clue. problem troubles me 1 week now. time! if need more information please let me know!
you have come right place! :)
i can 1 predicate object editor.
correct. nspredicateeditor
, not nspredicateseditor
. ;)
when use "predicateforrow:" returns
(null)
i'm not sure use method. general rule of thumb largely ignore nspredicateeditor
subclass of nsruleeditor
, because it's such highly specialized subclass many of superclass methods don't make sense on predicate editor (like stuff criteria, row selection, etc). it's possible they're somehow relevant, if are, haven't figured out how yet.
to predicate editor, do:
nspredicate *predicate = [mypredicateeditor objectvalue];
if user wants filter file name , size or date
you mean (name = [something]) , (size = [something] or date = [something])
?
if so, nspredicateeditor
can if you've set nesting mode "compound".
i can't use predicate on array anymore because information not contained in it
what information need?
can split predicate different predicates without converting nsstring object, search every @" or " | @" , " , seperating components array , converting every nsstring new predicate?
yes, bad idea. it's bad because nspredicate
contains information need, , converting different format , doing string manipulations isn't necessary , can potentially lead complications (like if can type in value "name", happens if type in " or "?).
i'm having hard time trying figure out you're trying do. sounds have array of nsstring
objects want filter based on predicate user creates? if so, these name
, date
, , size
key paths mean? trying do?
Comments
Post a Comment