re Boolean Predicates
re Boolean Predicates
- Subject: re Boolean Predicates
- From: John James <email@hidden>
- Date: Sun, 31 Oct 2004 09:28:03 -0500
I am a C++ programmer trying to learn Objective-C.
I probably don't understand the Objective-C features, but I am trying
to iterate over a list of objects (from the rear) and discover the
first one to satisfy a given boolean expression.
my code is:
@interface VectorOfStates : NSMutableArray
{
...
}
-(State*) FindLastIf:(SEL) aPred;
...
@end
// find last location on statestack
-(State*) FindLastIf:(SEL) aPred
{
NSEnumerator *enumerator = [self reverseObjectEnumerator];
id object;
while (object = [enumerator nextObject])
{
if((BOOL)[object aPred]) <------------------------- warning here
return (State*)object;
}
return nil;
}// FindLastIf:(SEL) aPred
I would call this with an selector that call a BOOL function such as:
SEL isState = @selector(IsState:);
[ses SetLocation: [self FindLastIf: isState]];
IsState is a method in the State class. VectorOfStates is as its name
implies an array of States.
I get the following warnings on the indicated line in the FindLastIf
method:
VectorOfStates.m:50: warning: cannot find method `-aPred'; return type
`id' assumed
VectorOfStates.m:50: warning: cast from pointer to integer of different
size
This makes me think I am doing something wrong.
Any advice?
Thanks in advance
John
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden