• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
re Boolean Predicates
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: re Boolean Predicates
      • From: Nick Zitzmann <email@hidden>
  • Prev by Date: Re: Determining the size of a directory Part 3
  • Next by Date: Re: nextKeyView and NSTabView: How to prevent the tabbing order from going out of the tab view?
  • Previous by thread: Re: Determining the size of a directory Part 3
  • Next by thread: Re: re Boolean Predicates
  • Index(es):
    • Date
    • Thread