Latest 0.4.0
Homepage https://github.com/ainame/INMEnum
License MIT
Platforms ios 7.0, requires ARC
Authors

CI Status
Version
License
Platform

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

@interface SushiGoRound : INMEnumCollection; @end
@interface Sushi : INMEnum; @end;
@implementation Sushi;  @end
@interface Tuna : Sushi; @end; @implementation Tuna; @end
@interface Egg : Sushi; @end; @implementation Egg; @end
@interface Shrimp : Sushi; @end; @implementation Shrimp; @end

@implementation SushiGoRound
+ (NSArray *) values
{
    return @[
        [Tuna defineEnum:0 name:@"tuna" description:@":sushi:"],
        [Egg defineEnum:1 name:@"egg" description:@":egg:"],
        [Shrimp defineEnum:2 name:@"shrimp" description:@":fried_shrimp:"],
    ];
}
@end

// ....

[INMEnumInitializer initializeAllEnumerateObjects]; // must call at first
Sushi *sushi = [tuna enumObject];
sushi.ordinal; //=> 0
sushi.name; //=> @"tuna"
sushi.description; //=> @":sushi:"

sushi = [sushi valueForName:@"egg"] // => Egg object;
[SushiGoRound values]               // => Tuna, Egg and Shrimp instances as NSArray;

// INMEnum's swtich case syntax
[SushiGoRound switch:sushi
               cases:[Tuna then:^{ NSLog(@"awesome!"); }],
                     [Egg then:^{ NSLog(@"yummy!!"); }],
                     [Shrimp then:^{ NSLog(@"delicious!!!"); }],
                     [INMEnumCaseDefault then:^{ NSLog(@"WTF!"); }]]; // must set at last

Constraints

  • You MUST initialize before touch one enum object by [INMEnumInitializer initializeAllEnumerateObjects].
  • You MUST given INMEnumCaseDefault section in swtich:cases: selector’s arguments.

Requirements

Installation

INMEnum is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "INMEnum"

Author

ainame

License

INMEnum is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "INMEnum",
    "version": "0.4.0",
    "summary": "INMEnum provide defining method to create a enum object as a plain old objc object.",
    "description": "INMEnum provide defining method to create a enum object as a plain old objc object.nThis almost realize the enum object like Java lang's one.",
    "homepage": "https://github.com/ainame/INMEnum",
    "license": "MIT",
    "authors": {
        "ainame": "[email protected]"
    },
    "source": {
        "git": "https://github.com/ainame/INMEnum.git",
        "tag": "0.4.0"
    },
    "social_media_url": "https://twitter.com/ainame",
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes"
}

Pin It on Pinterest

Share This