Latest 0.3.0
Homepage https://github.com/robb/Underscore.m
License MIT
Platforms ios 8.0, osx 10.7, requires ARC
Authors

About Underscore.m

Underscore.m is a small utility library to facilitate working with common data structures in Objective-C.
It tries to encourage chaining by eschewing the square bracket]]]]]].
It is inspired by the awesome underscore.js.

Real world example

// First, let's compose a twitter search request
NSURL *twitterSearch = [NSURL URLWithString:@"http://search.twitter.com/[email protected]&rpp=100"];

// ... then we fetch us some json ...
NSData *data = [NSData dataWithContentsOfURL:twitterSearch];

// ... and parse it.
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data
                                                     options:kNilOptions
                                                       error:NULL];

// This is where the fun starts!
NSArray *tweets = [json valueForKey:@"results"];

NSArray *processed = _array(tweets)
    // Let's make sure that we only operate on NSDictionaries, you never
    // know with these APIs ;-)
    .filter(Underscore.isDictionary)
    // Remove all tweets that are in English
    .reject(^BOOL (NSDictionary *tweet) {
        return [ isEqualToString:@"en"];
    })
    // Create a simple string representation for every tweet
    .map(^NSString *(NSDictionary *tweet) {
        NSString *name = ;
        NSString *text = ;

        return [NSString stringWithFormat:@"%@: %@", name, text];
    })
    .unwrap;

Documentation

Documentation for Underscore.m can be found on the website.

Latest podspec

{
    "name": "Underscore.m",
    "version": "0.3.0",
    "license": "MIT",
    "summary": "A functional toolbelt for Objective-C.",
    "homepage": "https://github.com/robb/Underscore.m",
    "authors": {
        "Robert Bu00f6hnke": "[email protected]"
    },
    "source": {
        "git": "https://github.com/robb/Underscore.m.git",
        "tag": "0.3.0"
    },
    "platforms": {
        "ios": "8.0",
        "osx": "10.7"
    },
    "description": "Underscore.m is an Objective-C library inspired by underscore.js.",
    "source_files": "Underscore/**/*.{h,m}",
    "requires_arc": true
}

Pin It on Pinterest

Share This