Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re Boolean Predicates



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.