Marketcircle    Forums  Hop To Forum Categories  Billings  Hop To Forums  Creating Estimates and Invoices    Filtering array of time entries according to date
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Veteran
Picture of adam
Posted
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
 
Posts: 643 | Location: san francisco bay area | Registered: June 09, 2006Reply With QuoteEdit or Delete MessageReport This Post
Apprentice
Posted Hide Post
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
 
Posts: 12 | Registered: June 07, 2008Reply With QuoteEdit or Delete MessageReport This Post
Veteran
Picture of adam
Posted Hide Post
Thanks, that did the trick! I will post my report later. smile


adam
 
Posts: 643 | Location: san francisco bay area | Registered: June 09, 2006Reply With QuoteEdit or Delete MessageReport This Post
 Previous Topic | Next Topic powered by eve community  
 

Marketcircle    Forums  Hop To Forum Categories  Billings  Hop To Forums  Creating Estimates and Invoices    Filtering array of time entries according to date

© Copyright 2006 Marketcircle Inc. All rights reserved.