• 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
predicateWithFormat: argumentArray:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

predicateWithFormat: argumentArray:


  • Subject: predicateWithFormat: argumentArray:
  • From: Nicholas Crosbie <email@hidden>
  • Date: Fri, 4 Nov 2005 12:26:14 +1100 (EST)

Hi list,

the following code returns "firstArray" filtered by
the first element of "secondArray" (value = 3).   How
--
using a predicate approach -- to filter firstArray
by ALL elements of secondArray.

 i.e. firstArray would contain 4 elements (3, 6, 9,
12)
after being filtered by secondArray.

- NDC

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {

	NSMutableArray *firstArray;
	NSMutableArray *secondArray;
	int i;
	NSNumber *newNumber;
	NSAutoreleasePool * pool = [[NSAutoreleasePool alloc]
init];

	   firstArray = [[NSMutableArray alloc] init];
	   secondArray = [[NSMutableArray alloc] init];

	   for ( i=1;  i<10; i++) {
	   newNumber = [[NSNumber alloc] initWithInt:(i *
3)];
	  [firstArray addObject:newNumber];
	  [newNumber release];
	   }

	  for ( i=1;  i<5; i++) {
	   newNumber = [[NSNumber alloc] initWithInt:(i *
3)];
	  [secondArray addObject:newNumber];
	  [newNumber release];
	   }

	NSLog(@"%@",firstArray);

	   printf ("\n");

	NSLog(@"%@",secondArray);


NSPredicate *thePredicate = [NSPredicate
 predicateWithFormat:@"SELF ==
%@"argumentArray:secondArray];
;
[firstArray filterUsingPredicate:thePredicate];

	   printf ("\n");

	NSLog(@"%@",firstArray);

	[firstArray release];
	[secondArray release];
	[pool release];
    return 0;
}



____________________________________________________
Do you Yahoo!?
Yahoo! on your mobile - Mail, Messenger, Movies and more!
http://au.mobile.yahoo.com/mweb/index.html
 _______________________________________________
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: predicateWithFormat: argumentArray:
      • From: mmalcolm crawford <email@hidden>
  • Prev by Date: Re: drop location feedback in NSTextView (2)
  • Next by Date: Re: DO and threads
  • Previous by thread: Re: drop location feedback in NSTextView
  • Next by thread: Re: predicateWithFormat: argumentArray:
  • Index(es):
    • Date
    • Thread