ReflectableEnum alternatives and similar libraries
Based on the "Utility" category.
Alternatively, view ReflectableEnum alternatives based on common mentions on social networks and blogs.
-
swift-algorithm-club
Algorithms and data structures in Swift, with explanations! -
SwifterSwift
A handy collection of more than 500 native Swift extensions to boost your productivity. -
BlocksKit
The Objective-C block utilities you always wish you had. -
libextobjc
A Cocoa library to extend the Objective-C programming language. -
InAppSettingsKit
This iOS framework allows settings to be in-app in addition to or instead of being in the Settings app. -
DifferenceKit
💻 A fast and flexible O(n) difference algorithm framework for Swift collection. -
EKAlgorithms
EKAlgorithms contains some well known CS algorithms & data structures. -
EZSwiftExtensions
:smirk: How Swift standard types and classes were supposed to work. -
Reusable
A Swift mixin for reusing views easily and in a type-safe way (UITableViewCells, UICollectionViewCells, custom UIViews, ViewControllers, Storyboards…) -
ObjectiveSugar
ObjectiveC additions for humans. Ruby style. -
WhatsNew
Showcase new features after an app update similar to Pages, Numbers and Keynote. -
SwiftLinkPreview
It makes a preview from an URL, grabbing all the information such as title, relevant texts and images. -
BFKit-Swift
BFKit-Swift is a collection of useful classes, structs and extensions to develop Apps faster. -
BFKit
BFKit is a collection of useful classes and categories to develop Apps faster. -
RateLimit
Simple utility for only executing code every so often. -
ReadabilityKit
Preview extractor for news, articles and full-texts in Swift -
VTAcknowledgementsViewController
Acknowledgements screen displaying a list of licenses, for example from CocoaPods dependencies. -
ObjectiveKit
Swift-friendly API for a set of powerful Objective C runtime functions. -
SwiftFoundation
Cross-Platform, Protocol-Oriented Programming base library to complement the Swift Standard Library. (Pure Swift, Supports Linux) -
AssistantKit
Easy way to detect iOS device properties, OS versions and work with screen sizes. Powered by Swift. -
DeviceGuru
DeviceGuru is a simple lib (Swift) to know the exact type of the device, e.g. iPhone 6 or iPhone 6s. Please ⭐️ this repo on the top right corner to make this repo popular. -
Eject
An eject button for Interface Builder to generate swift code -
SwiftyUtils
All the reusable code that we need in each project -
Retry
Haven't you wished for `try` to sometimes try a little harder? Meet `retry` -
Standard Template Protocols
Protocols for your every day iOS needs -
YAML.framework
Proper YAML support for Objective-C. Based on recommended libyaml. -
SBConstants
Generate a constants file by grabbing identifiers from storyboards in a project. -
ZamzamKit
A Swift package for rapid development using a collection of micro utility extensions for Standard Library, Foundation, and other native frameworks. -
XestiMonitors
An extensible monitoring framework written in Swift -
SwiftParsec
A parser combinator library written in the Swift programming language.
Appwrite - The open-source backend cloud platform
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of ReflectableEnum or a related project?
README
ReflectableEnum
A macro and a set of functions introducing reflection for enumerations in Objective-C.
Features:
- get a string value for an enumeration's member (which is a common problem)
- get all values used in an enumeration (also a prevalent issue)
- get a minimum value in an enumeration
- get a maximum value in an enumeration
- get an enumeration's member for a string (if it exists)
Usage
Once you have ReflectableEnum added to your project, you just need to replace existing enum definitions, like:
typedef NS_ENUM(NSUInteger, AccountType) {
AccountTypeStandard,
AccountTypeAdmin
};
with:
REFLECTABLE_ENUM(NSInteger, AccountType,
AccountTypeStandard,
AccountTypeAdmin
);
Now you can get a string representing an enumerator and all/minimum/maximum values of an enumeration the enumerator belongs to with:
AccountType accountType = AccountTypeStandard;
NSString *typeString = REFStringForMember(accountType); // @"AccountTypeStandard"
NSArray *allValues = REFAllValuesForEnumWithMember(accountType); // @[@0, @1]
NSInteger mininimum = REFMinForEnumWithMember(accountType); // 0
NSInteger maximum = REFMaxForEnumWithMember(accountType); // 1
AccountType accountType = REFMemberForString(accountType, @"AccountTypeAdmin"); // 1 (first argument is just for an enum type indication)
In case you pass the enumerator directly to one of these functions, you have to cast it to AccountType
, because the compiler doesn't know its type (it's treated as NSInteger
in this case):
NSString *typeString = REFStringForMember((AccountType)AccountTypeStandard);
NSArray *allValues = REFAllValuesForEnumWithMember((AccountType)AccountTypeStandard);
NSInteger mininimum = REFMinForEnumWithMember((AccountType)AccountTypeStandard);
NSInteger maximum = REFMaxForEnumWithMember((AccountType)AccountTypeStandard);
AccountType accountType = REFMemberForString((AccountType)0, @"AccountTypeAdmin"); // 1 (first argument is just for an enum type indication)
The need to cast is a hassle, so ReflectableEnum
will create enum-specific functions for you too:
NSString *typeString = REFStringForMemberInAccountType(AccountTypeStandard);
NSArray *allValues = REFAllValuesInAccountType();
NSInteger mininimum = REFMinInAccountType();
NSInteger maximum = REFMaxInAccountType();
AccountType accountType = REFMemberForStringInAccountType((AccountType)0, @"AccountTypeAdmin");
As you can see names of these functions depend on the name of the enumeration and follow these patterns: REFStringForMemberIn\(enumName)
, REFAllValuesIn\(enumName)
, REFMinIn\(enumName)
, REFMaxIn\(enumName)
and REFMemberForStringIn\(enumName)
.
Drawbacks
REFStringForMember
andREFStringForMemberIn\(enumName)
don't work with enumerations containing duplicated values, e.g. with self-referencing membersAccountTypeModerator = AccountTypeAdmin
- can't be used for enumerations already defined in frameworks and libraries
Requirements
- iOS 7 and above
- OS X 10.9 and above
Installation
Install with Carthage:
github "fastred/ReflectableEnum"
or with CocoaPods:
pod "ReflectableEnum"
And then import with: #import <ReflectableEnum/ReflectableEnum.h>
Author
Arkadiusz Holko: