Open Source Library Bringing Microsoft .NET Linq Style Queries To Objective-C Collections

Previously I mentioned the iOS-Queryable framework that provides a Microsoft .NET LINQ style syntax for creating core data queries.

Anton Bukov has created a project called NSEnumeratorLinq that aims to provide an API modeled after the Linq Enumerable API found in .NET providing an extensive number of methods for easier queries of Objectice-c collections.

Here’s an example from the NSEnumeratorLinq readme showing use of the library on an NSArray:

NSArray * arr = @[@1,@2,@3,@4,@5,@6,@7,@8];
NSArray * subarr = [[[[[arr objectEnumerator]                                // 1,2,3,4,5,6,7,8
                    where:^(id a){return [a intValue]%2 == 1}]               // 1,3,5,7
                    select:^(id a){return @([a intValue]*2)}]                // 2,6,10,14
                    where:^(id a){return [a intValue]>2 && [a intValue]<12}] // 6,10
                    allObjects];

You can find NSEnumeratorLinq on Github here.

There are many methods available that you’ll find listed on the Github page.

DeliciousTwitterFacebookRedditLinkedInEmail

Original article: Open Source Library Bringing Microsoft .NET Linq Style Queries To Objective-C Collections

©2013 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.

Leave a Reply

Your email address will not be published. Required fields are marked *