Predicate Row Template array within array

2014-11-30 Thread Trygve Inda
I have an array of objects that looks like:

{
   NSString*  name;
   NSDate*date;
   NSArray*   words;
}

The words array looks like:

{
   NSString*  id;
   NSString*  word;
}


I need to build a Predicate Row template to result in a way to search for
names, dates, and words. The first two are easy using basically:

[NSExpression expressionForKeyPath:@name];

template = [[NSPredicateEditorRowTemplate alloc]
initWithLeftExpressions:expressions
rightExpressionAttributeType:NSStringAttributeType
modifier:NSDirectPredicateModifier
operators:operators
options:0];

This gives me a predicate:

name CONTAINS[cd] Fred

But how can I build a row template to search for an object whose words
array contains a specific word?

Just in code it would be:

predicate = [NSPredicate predicateWithFormat:@%@ IN words, someword];

How can I apply that sort of logic to my row template so that the left
expression would be words, operators would be:

NSBeginsWithPredicateOperatorType
NSEndsWithPredicateOperatorType
NSContainsPredicateOperatorType

But that would give me:

words CONTAINS[cd] Fred

Which is not what I want.

How can I get the effect of the %@ IN words in a row template? This will
cause it to search for objects that contain a words array that contains a
specific word.

Thanks,

Trygve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Predicate Row Template array within array

2014-11-30 Thread Trygve Inda
{
   
NSString*  name;
NSDate*date;
NSArray*   words;
}
Objects;

The words array looks like:
{
  
NSString*  id;
NSString*  word;
}
Words;


As a follow up:

When I use a left expression of:

@words.word

And a modifier of: NSAnyPredicateModifier

My predicate ends up as:

ANY words.word CONTAINS[cd] Test

But I get:
[__NSCFString 0x61277d00 valueForUndefinedKey:]: this class is not key
value coding-compliant for the key word.

But it is.

My class has

@property (copy, readwrite)NSString* id;
@property (copy, readwrite)NSString* word;

And they are synthesized

I am not sure what class it is trying to look at since it does not indicate
that.

Any ideas?



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Predicate Row Template array within array

2014-11-30 Thread Keary Suska
On Nov 30, 2014, at 9:02 AM, Trygve Inda cocoa...@xericdesign.com wrote:

 {
 
 NSString*  name;
 NSDate*date;
 NSArray*   words;
 }
 Objects;
 
 The words array looks like:
 {
 
 NSString*  id;
 NSString*  word;
 }
 Words;
 
 
 As a follow up:
 
 When I use a left expression of:
 
 @words.word
 
 And a modifier of: NSAnyPredicateModifier
 
 My predicate ends up as:
 
 ANY words.word CONTAINS[cd] Test
 
 But I get:
 [__NSCFString 0x61277d00 valueForUndefinedKey:]: this class is not key
 value coding-compliant for the key word.
 
 But it is.

Notice that the object being queried is an NSString, and not the expected 
word object. This either means that your words array contains at least one 
plain NSString, or you are experiencing a memory management issue. Break on 
exception and see what is in that NSString.

HTH,

Keary Suska
Esoteritech, Inc.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com