Found on GitHub: ObjectiveSugar

Image of code from ilya-pavlov

Octocat logo

Marin Usalj has written a collection of extensions for the NSNumber, NSArray, NSSet, NSString, and NSDictionary classes that brings many of the commonly used methods from their Ruby counterparts such as each or times. If you’re familiar with Ruby and doing some iOS or Mac development these extensions can definitely save you some work.

Check out the samples below, pulled from the ObjectiveSugar ReadMe and add the code to your project using Cocoapods.

[@3 times:^{
  NSLog(@"Hello World!");
// Hello World!
// Hello World!
// Hello World!


NSArray *cars = [@"Testarossa", @"F50", @"F458 Italia"]; 
// or NSSet *cars = [NSSet setWithObjects:@"Testarossa", @"F50", @"F458 Italia", nil];

[cars map:^id(id car){
    return @([[car substringToIndex:1] isEqualToString:@"F"]);
// NO (Testarossa)
// YES (F50)
// YES (F458 Italia)
Steven Huey

Steven Huey

Senior Software Engineer at Art & Logic
Mac and iOS developer and project manager at Art+Logic. Twitter | GitHub
Steven Huey
@pxlnv Philip Morris has done this for a while to circumvent tobacco advertising laws with: - 1 year ago
Steven Huey


Creative Commons License

This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.