Created: 2012-03-20 22:23
Updated: 2014-06-07 03:22
License: other

LinqKit is a proposal for implementing the functionality known as Linq (Language Integrated Query) in .NET, but then for Objective-C.

Currently it is implemented as Categories on NSObject. It works with deferred execution by using custom NSEnumerator subclasses.

For the moment basic implementations of where, select, skip and take have been implemented. Any additions or suggestions are welcomed.

The syntax that I defined looks like this:

NSArray *arr = [[NSArray alloc]initWithObjects:@"one", 
  @"two", @"three", @"four", @"five", @"six", @"seven", @"eight", @"nine", 
  @"ten", @"eleven", @"twelve", @"thirteen", @"fourteen", @"fifteen",
  @"sixteen", @"seventeen", @"eighteen", @"nineteen", @"twenty", nil];

for(id string in [[[[arr where:^BOOL(id t){ return ![t hasPrefix:@"e"]; }] 
    select:^id(id r) { return [NSString stringWithFormat:@"result : %@", r]; } ])
  NSLog(@"%@", string);

Kind regard, Jeroen

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more