Forums
Billings
Creating Estimates and Invoices
Filtering array of time entries according to date|
Go
![]() |
New
![]() |
Find
![]() |
Notify
![]() |
Tools
![]() |
Reply
![]() |
|
|
Veteran |
I have a report that shows one slip per row. For each slip, I get its time entries in an array called matchingTimeEntries
I want to filter that array so that I'm left with only those time entries that have a startDateTime between a start and end that are specified in userInput. My problem is that I can't seem to create a filterPredicate that will allow me to filter the array. For example: start := userInput valueForKey:'startDate'. start := start dateAsBeginningOfDay. filterPredicate := (NSPredicate predicateWithFormat:'startDateTime > start'). matchingTimeEntries := matchingTimeEntries filteredArrayUsingPredicate:filterPredicate. Results in an error: NSUnknownKeyException: [<BITimeEntry 0x15073630> valueForUndefinedKey:]: this class is not key value coding-compliant for the key start. How can I create a filter predicate that matches a key to a variable value as in this case (the variable value being the user input)? Thanks, adam adam |
||
|
|
Apprentice |
Hi adam,
I needed to filter an array of slips by startDate, and also couldn't figure out how to do it with "filteredArrayUsingPredicate". However, I did find that this works: qual1 := BDKeyValueQualifier keyValueQualifierWithKey:'startDateTime' operatorSelector:#isGreaterThan: value:start.
qual2 := BDKeyValueQualifier keyValueQualifierWithKey:'startDateTime' operatorSelector:#isLessThan: value:end.
qualifiers := {qual1, qual2}.
andQual := (((BDAndQualifier alloc) initWithQualifierArray:qualifiers) autorelease).
slipsForTable := slipsForTable filteredArrayUsingQualifier:andQual. (I can't remember how I figured that out, I probably cribbed it from the forum somewhere.) You might be able to do something similar. Best, Chris |
|||
|
|
Veteran |
Thanks, that did the trick! I will post my report later.
adam |
|||
|
| Previous Topic | Next Topic | powered by eve community |
| Please Wait. Your request is being processed... |
|
Forums
Billings
Creating Estimates and Invoices
Filtering array of time entries according to date
