{"id":20678951,"url":"https://github.com/fastred/reflectableenum","last_synced_at":"2025-08-27T07:17:44.325Z","repository":{"id":32168638,"uuid":"35741882","full_name":"fastred/ReflectableEnum","owner":"fastred","description":"Reflection for enumerations in Objective-C.","archived":false,"fork":false,"pushed_at":"2017-01-28T10:46:29.000Z","size":33,"stargazers_count":333,"open_issues_count":4,"forks_count":12,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-08-01T17:03:16.702Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fastred.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-16T22:00:09.000Z","updated_at":"2025-07-18T02:22:18.000Z","dependencies_parsed_at":"2022-09-11T11:22:46.646Z","dependency_job_id":null,"html_url":"https://github.com/fastred/ReflectableEnum","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/fastred/ReflectableEnum","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastred%2FReflectableEnum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastred%2FReflectableEnum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastred%2FReflectableEnum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastred%2FReflectableEnum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fastred","download_url":"https://codeload.github.com/fastred/ReflectableEnum/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastred%2FReflectableEnum/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272303390,"owners_count":24910374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-27T02:00:09.397Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T21:23:16.630Z","updated_at":"2025-08-27T07:17:44.295Z","avatar_url":"https://github.com/fastred.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ReflectableEnum\n\n[![Build Status](https://travis-ci.org/fastred/ReflectableEnum.svg?branch=master)](https://travis-ci.org/fastred/ReflectableEnum)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n\nA macro and a set of functions introducing reflection for enumerations in Objective-C.\n\nFeatures:\n\n- get a string value for an enumeration's member (which is a [\u003cu\u003ecommon\u003c/u\u003e][1] [\u003cu\u003eproblem\u003c/u\u003e][2])\n- get all values used in an enumeration (also a [\u003cu\u003eprevalent\u003c/u\u003e][3] [\u003cu\u003eissue\u003c/u\u003e][4])\n- get a minimum value in an enumeration\n- get a maximum value in an enumeration\n- get an enumeration's member for a string (if it exists)\n\n## Usage\n\nOnce you have ReflectableEnum added to your project, you just need to replace existing enum definitions, like:\n\n```obj-c\ntypedef NS_ENUM(NSUInteger, AccountType) {\n  AccountTypeStandard,\n  AccountTypeAdmin\n};\n```\n\nwith:\n\n```obj-c\nREFLECTABLE_ENUM(NSInteger, AccountType,\n  AccountTypeStandard,\n  AccountTypeAdmin\n);\n```\n\nNow you can get a string representing an enumerator and all/minimum/maximum values of an enumeration the enumerator belongs to with:\n\n```obj-c\nAccountType accountType = AccountTypeStandard;\nNSString *typeString = REFStringForMember(accountType);          // @\"AccountTypeStandard\"\nNSArray *allValues = REFAllValuesForEnumWithMember(accountType); // @[@0, @1]\nNSInteger mininimum = REFMinForEnumWithMember(accountType);      // 0\nNSInteger maximum = REFMaxForEnumWithMember(accountType);        // 1\nAccountType accountType = REFMemberForString(accountType, @\"AccountTypeAdmin\"); // 1 (first argument is just for an enum type indication)\n```\n\nIn 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):\n\n```obj-c\nNSString *typeString = REFStringForMember((AccountType)AccountTypeStandard);\nNSArray *allValues = REFAllValuesForEnumWithMember((AccountType)AccountTypeStandard);\nNSInteger mininimum = REFMinForEnumWithMember((AccountType)AccountTypeStandard);\nNSInteger maximum = REFMaxForEnumWithMember((AccountType)AccountTypeStandard);\nAccountType accountType = REFMemberForString((AccountType)0, @\"AccountTypeAdmin\"); // 1 (first argument is just for an enum type indication)\n\n```\n\nThe need to cast is a hassle, so `ReflectableEnum` will create enum-specific functions for you too:\n\n```obj-c\nNSString *typeString = REFStringForMemberInAccountType(AccountTypeStandard);\nNSArray *allValues = REFAllValuesInAccountType();\nNSInteger mininimum = REFMinInAccountType();\nNSInteger maximum = REFMaxInAccountType();\nAccountType accountType = REFMemberForStringInAccountType((AccountType)0, @\"AccountTypeAdmin\");\n```\n\nAs 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)`.\n\n## Drawbacks\n\n- `REFStringForMember` and `REFStringForMemberIn\\(enumName)` don't work with enumerations containing duplicated values, e.g. with self-referencing members `AccountTypeModerator = AccountTypeAdmin`\n- can't be used for enumerations already defined in frameworks and libraries\n\n## Requirements\n\n * iOS 7 and above\n * OS X 10.9 and above\n\n## Installation\n\nInstall with Carthage:\n\n    github \"fastred/ReflectableEnum\"\n\nor with CocoaPods:\n\n    pod \"ReflectableEnum\"\n\nAnd then import with: `#import \u003cReflectableEnum/ReflectableEnum.h\u003e`\n\n## Author\n\nArkadiusz Holko:\n\n* [Blog](http://holko.pl/)\n* [@arekholko on Twitter](https://twitter.com/arekholko)\n\n  [1]:http://stackoverflow.com/questions/6331762/enum-values-to-nsstring-ios\n  [2]:http://stackoverflow.com/questions/1094984/convert-objective-c-typedef-to-its-string-equivalent\n  [3]:http://stackoverflow.com/questions/6910127/iteration-over-enum-in-objective-c\n  [4]:http://stackoverflow.com/questions/1662719/looping-through-enum-values\n  [5]:http://www.openradar.me/radar?id=6679230377099264\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastred%2Freflectableenum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffastred%2Freflectableenum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastred%2Freflectableenum/lists"}