├── Enumerable.podspec ├── Enumerable.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── hirose.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── hirose.xcuserdatad │ └── xcschemes │ ├── Enumerable.xcscheme │ └── xcschememanagement.plist ├── Enumerable ├── Enumerable.h ├── Enumerable.swift └── Info.plist ├── EnumerableTests ├── EnumerableTests.swift └── Info.plist ├── LICENSE └── README.md /Enumerable.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint Enumerable.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | s.name = "Enumerable" 11 | s.version = "0.0.1" 12 | s.summary = "Swift Enum can enumerable." 13 | s.description = <<-DESC 14 | Enumrable can get all the elements of Enum. 15 | DESC 16 | s.homepage = "https://github.com/bannzai/Enumerable" 17 | s.license = "MIT" 18 | s.author = { "bannzai" => "kingkong999yhirose@gmail.com" } 19 | s.source = { :git => "https://github.com/bannzai/Enumerable.git", :commit => "e27286afd3c824d57d3287f1ff38242fdcf7b602" } 20 | s.source_files = "Enumerable/*.swift" 21 | s.social_media_url = "https://twitter.com/_bannzai_" 22 | s.ios.deployment_target = '9.0' 23 | s.swift_version = '4.1' 24 | end 25 | -------------------------------------------------------------------------------- /Enumerable.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 6C495F251F53DC1000C82503 /* Enumerable.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6C495F1B1F53DC1000C82503 /* Enumerable.framework */; }; 11 | 6C495F2A1F53DC1000C82503 /* EnumerableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C495F291F53DC1000C82503 /* EnumerableTests.swift */; }; 12 | 6C495F2C1F53DC1000C82503 /* Enumerable.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C495F1E1F53DC1000C82503 /* Enumerable.h */; settings = {ATTRIBUTES = (Public, ); }; }; 13 | 6C495F361F53DC2400C82503 /* Enumerable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C495F351F53DC2400C82503 /* Enumerable.swift */; }; 14 | /* End PBXBuildFile section */ 15 | 16 | /* Begin PBXContainerItemProxy section */ 17 | 6C495F261F53DC1000C82503 /* PBXContainerItemProxy */ = { 18 | isa = PBXContainerItemProxy; 19 | containerPortal = 6C495F121F53DC1000C82503 /* Project object */; 20 | proxyType = 1; 21 | remoteGlobalIDString = 6C495F1A1F53DC1000C82503; 22 | remoteInfo = Enumerable; 23 | }; 24 | /* End PBXContainerItemProxy section */ 25 | 26 | /* Begin PBXFileReference section */ 27 | 6C495F1B1F53DC1000C82503 /* Enumerable.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Enumerable.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 28 | 6C495F1E1F53DC1000C82503 /* Enumerable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Enumerable.h; sourceTree = ""; }; 29 | 6C495F1F1F53DC1000C82503 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 30 | 6C495F241F53DC1000C82503 /* EnumerableTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = EnumerableTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 31 | 6C495F291F53DC1000C82503 /* EnumerableTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnumerableTests.swift; sourceTree = ""; }; 32 | 6C495F2B1F53DC1000C82503 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | 6C495F351F53DC2400C82503 /* Enumerable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Enumerable.swift; sourceTree = ""; }; 34 | /* End PBXFileReference section */ 35 | 36 | /* Begin PBXFrameworksBuildPhase section */ 37 | 6C495F171F53DC1000C82503 /* Frameworks */ = { 38 | isa = PBXFrameworksBuildPhase; 39 | buildActionMask = 2147483647; 40 | files = ( 41 | ); 42 | runOnlyForDeploymentPostprocessing = 0; 43 | }; 44 | 6C495F211F53DC1000C82503 /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | 6C495F251F53DC1000C82503 /* Enumerable.framework in Frameworks */, 49 | ); 50 | runOnlyForDeploymentPostprocessing = 0; 51 | }; 52 | /* End PBXFrameworksBuildPhase section */ 53 | 54 | /* Begin PBXGroup section */ 55 | 6C495F111F53DC1000C82503 = { 56 | isa = PBXGroup; 57 | children = ( 58 | 6C495F1D1F53DC1000C82503 /* Enumerable */, 59 | 6C495F281F53DC1000C82503 /* EnumerableTests */, 60 | 6C495F1C1F53DC1000C82503 /* Products */, 61 | ); 62 | sourceTree = ""; 63 | }; 64 | 6C495F1C1F53DC1000C82503 /* Products */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | 6C495F1B1F53DC1000C82503 /* Enumerable.framework */, 68 | 6C495F241F53DC1000C82503 /* EnumerableTests.xctest */, 69 | ); 70 | name = Products; 71 | sourceTree = ""; 72 | }; 73 | 6C495F1D1F53DC1000C82503 /* Enumerable */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | 6C495F1E1F53DC1000C82503 /* Enumerable.h */, 77 | 6C495F1F1F53DC1000C82503 /* Info.plist */, 78 | 6C495F351F53DC2400C82503 /* Enumerable.swift */, 79 | ); 80 | path = Enumerable; 81 | sourceTree = ""; 82 | }; 83 | 6C495F281F53DC1000C82503 /* EnumerableTests */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | 6C495F291F53DC1000C82503 /* EnumerableTests.swift */, 87 | 6C495F2B1F53DC1000C82503 /* Info.plist */, 88 | ); 89 | path = EnumerableTests; 90 | sourceTree = ""; 91 | }; 92 | /* End PBXGroup section */ 93 | 94 | /* Begin PBXHeadersBuildPhase section */ 95 | 6C495F181F53DC1000C82503 /* Headers */ = { 96 | isa = PBXHeadersBuildPhase; 97 | buildActionMask = 2147483647; 98 | files = ( 99 | 6C495F2C1F53DC1000C82503 /* Enumerable.h in Headers */, 100 | ); 101 | runOnlyForDeploymentPostprocessing = 0; 102 | }; 103 | /* End PBXHeadersBuildPhase section */ 104 | 105 | /* Begin PBXNativeTarget section */ 106 | 6C495F1A1F53DC1000C82503 /* Enumerable */ = { 107 | isa = PBXNativeTarget; 108 | buildConfigurationList = 6C495F2F1F53DC1000C82503 /* Build configuration list for PBXNativeTarget "Enumerable" */; 109 | buildPhases = ( 110 | 6C495F161F53DC1000C82503 /* Sources */, 111 | 6C495F171F53DC1000C82503 /* Frameworks */, 112 | 6C495F181F53DC1000C82503 /* Headers */, 113 | 6C495F191F53DC1000C82503 /* Resources */, 114 | ); 115 | buildRules = ( 116 | ); 117 | dependencies = ( 118 | ); 119 | name = Enumerable; 120 | productName = Enumerable; 121 | productReference = 6C495F1B1F53DC1000C82503 /* Enumerable.framework */; 122 | productType = "com.apple.product-type.framework"; 123 | }; 124 | 6C495F231F53DC1000C82503 /* EnumerableTests */ = { 125 | isa = PBXNativeTarget; 126 | buildConfigurationList = 6C495F321F53DC1000C82503 /* Build configuration list for PBXNativeTarget "EnumerableTests" */; 127 | buildPhases = ( 128 | 6C495F201F53DC1000C82503 /* Sources */, 129 | 6C495F211F53DC1000C82503 /* Frameworks */, 130 | 6C495F221F53DC1000C82503 /* Resources */, 131 | ); 132 | buildRules = ( 133 | ); 134 | dependencies = ( 135 | 6C495F271F53DC1000C82503 /* PBXTargetDependency */, 136 | ); 137 | name = EnumerableTests; 138 | productName = EnumerableTests; 139 | productReference = 6C495F241F53DC1000C82503 /* EnumerableTests.xctest */; 140 | productType = "com.apple.product-type.bundle.unit-test"; 141 | }; 142 | /* End PBXNativeTarget section */ 143 | 144 | /* Begin PBXProject section */ 145 | 6C495F121F53DC1000C82503 /* Project object */ = { 146 | isa = PBXProject; 147 | attributes = { 148 | LastSwiftUpdateCheck = 0830; 149 | LastUpgradeCheck = 0830; 150 | ORGANIZATIONNAME = Hirose.Yudai; 151 | TargetAttributes = { 152 | 6C495F1A1F53DC1000C82503 = { 153 | CreatedOnToolsVersion = 8.3.3; 154 | LastSwiftMigration = 0830; 155 | ProvisioningStyle = Automatic; 156 | }; 157 | 6C495F231F53DC1000C82503 = { 158 | CreatedOnToolsVersion = 8.3.3; 159 | ProvisioningStyle = Automatic; 160 | }; 161 | }; 162 | }; 163 | buildConfigurationList = 6C495F151F53DC1000C82503 /* Build configuration list for PBXProject "Enumerable" */; 164 | compatibilityVersion = "Xcode 3.2"; 165 | developmentRegion = English; 166 | hasScannedForEncodings = 0; 167 | knownRegions = ( 168 | en, 169 | ); 170 | mainGroup = 6C495F111F53DC1000C82503; 171 | productRefGroup = 6C495F1C1F53DC1000C82503 /* Products */; 172 | projectDirPath = ""; 173 | projectRoot = ""; 174 | targets = ( 175 | 6C495F1A1F53DC1000C82503 /* Enumerable */, 176 | 6C495F231F53DC1000C82503 /* EnumerableTests */, 177 | ); 178 | }; 179 | /* End PBXProject section */ 180 | 181 | /* Begin PBXResourcesBuildPhase section */ 182 | 6C495F191F53DC1000C82503 /* Resources */ = { 183 | isa = PBXResourcesBuildPhase; 184 | buildActionMask = 2147483647; 185 | files = ( 186 | ); 187 | runOnlyForDeploymentPostprocessing = 0; 188 | }; 189 | 6C495F221F53DC1000C82503 /* Resources */ = { 190 | isa = PBXResourcesBuildPhase; 191 | buildActionMask = 2147483647; 192 | files = ( 193 | ); 194 | runOnlyForDeploymentPostprocessing = 0; 195 | }; 196 | /* End PBXResourcesBuildPhase section */ 197 | 198 | /* Begin PBXSourcesBuildPhase section */ 199 | 6C495F161F53DC1000C82503 /* Sources */ = { 200 | isa = PBXSourcesBuildPhase; 201 | buildActionMask = 2147483647; 202 | files = ( 203 | 6C495F361F53DC2400C82503 /* Enumerable.swift in Sources */, 204 | ); 205 | runOnlyForDeploymentPostprocessing = 0; 206 | }; 207 | 6C495F201F53DC1000C82503 /* Sources */ = { 208 | isa = PBXSourcesBuildPhase; 209 | buildActionMask = 2147483647; 210 | files = ( 211 | 6C495F2A1F53DC1000C82503 /* EnumerableTests.swift in Sources */, 212 | ); 213 | runOnlyForDeploymentPostprocessing = 0; 214 | }; 215 | /* End PBXSourcesBuildPhase section */ 216 | 217 | /* Begin PBXTargetDependency section */ 218 | 6C495F271F53DC1000C82503 /* PBXTargetDependency */ = { 219 | isa = PBXTargetDependency; 220 | target = 6C495F1A1F53DC1000C82503 /* Enumerable */; 221 | targetProxy = 6C495F261F53DC1000C82503 /* PBXContainerItemProxy */; 222 | }; 223 | /* End PBXTargetDependency section */ 224 | 225 | /* Begin XCBuildConfiguration section */ 226 | 6C495F2D1F53DC1000C82503 /* Debug */ = { 227 | isa = XCBuildConfiguration; 228 | buildSettings = { 229 | ALWAYS_SEARCH_USER_PATHS = NO; 230 | CLANG_ANALYZER_NONNULL = YES; 231 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 232 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 233 | CLANG_CXX_LIBRARY = "libc++"; 234 | CLANG_ENABLE_MODULES = YES; 235 | CLANG_ENABLE_OBJC_ARC = YES; 236 | CLANG_WARN_BOOL_CONVERSION = YES; 237 | CLANG_WARN_CONSTANT_CONVERSION = YES; 238 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 239 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 240 | CLANG_WARN_EMPTY_BODY = YES; 241 | CLANG_WARN_ENUM_CONVERSION = YES; 242 | CLANG_WARN_INFINITE_RECURSION = YES; 243 | CLANG_WARN_INT_CONVERSION = YES; 244 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 245 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 246 | CLANG_WARN_UNREACHABLE_CODE = YES; 247 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 248 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 249 | COPY_PHASE_STRIP = NO; 250 | CURRENT_PROJECT_VERSION = 1; 251 | DEBUG_INFORMATION_FORMAT = dwarf; 252 | ENABLE_STRICT_OBJC_MSGSEND = YES; 253 | ENABLE_TESTABILITY = YES; 254 | GCC_C_LANGUAGE_STANDARD = gnu99; 255 | GCC_DYNAMIC_NO_PIC = NO; 256 | GCC_NO_COMMON_BLOCKS = YES; 257 | GCC_OPTIMIZATION_LEVEL = 0; 258 | GCC_PREPROCESSOR_DEFINITIONS = ( 259 | "DEBUG=1", 260 | "$(inherited)", 261 | ); 262 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 263 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 264 | GCC_WARN_UNDECLARED_SELECTOR = YES; 265 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 266 | GCC_WARN_UNUSED_FUNCTION = YES; 267 | GCC_WARN_UNUSED_VARIABLE = YES; 268 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 269 | MTL_ENABLE_DEBUG_INFO = YES; 270 | ONLY_ACTIVE_ARCH = YES; 271 | SDKROOT = iphoneos; 272 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 273 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 274 | TARGETED_DEVICE_FAMILY = "1,2"; 275 | VERSIONING_SYSTEM = "apple-generic"; 276 | VERSION_INFO_PREFIX = ""; 277 | }; 278 | name = Debug; 279 | }; 280 | 6C495F2E1F53DC1000C82503 /* Release */ = { 281 | isa = XCBuildConfiguration; 282 | buildSettings = { 283 | ALWAYS_SEARCH_USER_PATHS = NO; 284 | CLANG_ANALYZER_NONNULL = YES; 285 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 286 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 287 | CLANG_CXX_LIBRARY = "libc++"; 288 | CLANG_ENABLE_MODULES = YES; 289 | CLANG_ENABLE_OBJC_ARC = YES; 290 | CLANG_WARN_BOOL_CONVERSION = YES; 291 | CLANG_WARN_CONSTANT_CONVERSION = YES; 292 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 293 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 294 | CLANG_WARN_EMPTY_BODY = YES; 295 | CLANG_WARN_ENUM_CONVERSION = YES; 296 | CLANG_WARN_INFINITE_RECURSION = YES; 297 | CLANG_WARN_INT_CONVERSION = YES; 298 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 299 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 300 | CLANG_WARN_UNREACHABLE_CODE = YES; 301 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 302 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 303 | COPY_PHASE_STRIP = NO; 304 | CURRENT_PROJECT_VERSION = 1; 305 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 306 | ENABLE_NS_ASSERTIONS = NO; 307 | ENABLE_STRICT_OBJC_MSGSEND = YES; 308 | GCC_C_LANGUAGE_STANDARD = gnu99; 309 | GCC_NO_COMMON_BLOCKS = YES; 310 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 311 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 312 | GCC_WARN_UNDECLARED_SELECTOR = YES; 313 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 314 | GCC_WARN_UNUSED_FUNCTION = YES; 315 | GCC_WARN_UNUSED_VARIABLE = YES; 316 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 317 | MTL_ENABLE_DEBUG_INFO = NO; 318 | SDKROOT = iphoneos; 319 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 320 | TARGETED_DEVICE_FAMILY = "1,2"; 321 | VALIDATE_PRODUCT = YES; 322 | VERSIONING_SYSTEM = "apple-generic"; 323 | VERSION_INFO_PREFIX = ""; 324 | }; 325 | name = Release; 326 | }; 327 | 6C495F301F53DC1000C82503 /* Debug */ = { 328 | isa = XCBuildConfiguration; 329 | buildSettings = { 330 | CLANG_ENABLE_MODULES = YES; 331 | CODE_SIGN_IDENTITY = ""; 332 | DEFINES_MODULE = YES; 333 | DYLIB_COMPATIBILITY_VERSION = 1; 334 | DYLIB_CURRENT_VERSION = 1; 335 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 336 | INFOPLIST_FILE = Enumerable/Info.plist; 337 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 338 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 339 | PRODUCT_BUNDLE_IDENTIFIER = "com.moneyfwd.chalin-framework.Enumerable"; 340 | PRODUCT_NAME = "$(TARGET_NAME)"; 341 | SKIP_INSTALL = YES; 342 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 343 | SWIFT_VERSION = 3.0; 344 | }; 345 | name = Debug; 346 | }; 347 | 6C495F311F53DC1000C82503 /* Release */ = { 348 | isa = XCBuildConfiguration; 349 | buildSettings = { 350 | CLANG_ENABLE_MODULES = YES; 351 | CODE_SIGN_IDENTITY = ""; 352 | DEFINES_MODULE = YES; 353 | DYLIB_COMPATIBILITY_VERSION = 1; 354 | DYLIB_CURRENT_VERSION = 1; 355 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 356 | INFOPLIST_FILE = Enumerable/Info.plist; 357 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 358 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 359 | PRODUCT_BUNDLE_IDENTIFIER = "com.moneyfwd.chalin-framework.Enumerable"; 360 | PRODUCT_NAME = "$(TARGET_NAME)"; 361 | SKIP_INSTALL = YES; 362 | SWIFT_VERSION = 3.0; 363 | }; 364 | name = Release; 365 | }; 366 | 6C495F331F53DC1000C82503 /* Debug */ = { 367 | isa = XCBuildConfiguration; 368 | buildSettings = { 369 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 370 | INFOPLIST_FILE = EnumerableTests/Info.plist; 371 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 372 | PRODUCT_BUNDLE_IDENTIFIER = "com.moneyfwd.chalin-framework.EnumerableTests"; 373 | PRODUCT_NAME = "$(TARGET_NAME)"; 374 | SWIFT_VERSION = 3.0; 375 | }; 376 | name = Debug; 377 | }; 378 | 6C495F341F53DC1000C82503 /* Release */ = { 379 | isa = XCBuildConfiguration; 380 | buildSettings = { 381 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 382 | INFOPLIST_FILE = EnumerableTests/Info.plist; 383 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 384 | PRODUCT_BUNDLE_IDENTIFIER = "com.moneyfwd.chalin-framework.EnumerableTests"; 385 | PRODUCT_NAME = "$(TARGET_NAME)"; 386 | SWIFT_VERSION = 3.0; 387 | }; 388 | name = Release; 389 | }; 390 | /* End XCBuildConfiguration section */ 391 | 392 | /* Begin XCConfigurationList section */ 393 | 6C495F151F53DC1000C82503 /* Build configuration list for PBXProject "Enumerable" */ = { 394 | isa = XCConfigurationList; 395 | buildConfigurations = ( 396 | 6C495F2D1F53DC1000C82503 /* Debug */, 397 | 6C495F2E1F53DC1000C82503 /* Release */, 398 | ); 399 | defaultConfigurationIsVisible = 0; 400 | defaultConfigurationName = Release; 401 | }; 402 | 6C495F2F1F53DC1000C82503 /* Build configuration list for PBXNativeTarget "Enumerable" */ = { 403 | isa = XCConfigurationList; 404 | buildConfigurations = ( 405 | 6C495F301F53DC1000C82503 /* Debug */, 406 | 6C495F311F53DC1000C82503 /* Release */, 407 | ); 408 | defaultConfigurationIsVisible = 0; 409 | }; 410 | 6C495F321F53DC1000C82503 /* Build configuration list for PBXNativeTarget "EnumerableTests" */ = { 411 | isa = XCConfigurationList; 412 | buildConfigurations = ( 413 | 6C495F331F53DC1000C82503 /* Debug */, 414 | 6C495F341F53DC1000C82503 /* Release */, 415 | ); 416 | defaultConfigurationIsVisible = 0; 417 | }; 418 | /* End XCConfigurationList section */ 419 | }; 420 | rootObject = 6C495F121F53DC1000C82503 /* Project object */; 421 | } 422 | -------------------------------------------------------------------------------- /Enumerable.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Enumerable.xcodeproj/project.xcworkspace/xcuserdata/hirose.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bannzai/Enumerable/e00476d7491785a23bbacc7c7d906a5991cb9f06/Enumerable.xcodeproj/project.xcworkspace/xcuserdata/hirose.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Enumerable.xcodeproj/xcuserdata/hirose.xcuserdatad/xcschemes/Enumerable.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 65 | 71 | 72 | 73 | 74 | 75 | 76 | 82 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /Enumerable.xcodeproj/xcuserdata/hirose.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Enumerable.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 6C495F1A1F53DC1000C82503 16 | 17 | primary 18 | 19 | 20 | 6C495F231F53DC1000C82503 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Enumerable/Enumerable.h: -------------------------------------------------------------------------------- 1 | // 2 | // Enumerable.h 3 | // Enumerable 4 | // 5 | // Created by Hirose.Yudai on 2017/08/28. 6 | // Copyright © 2017年 Hirose.Yudai. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Enumerable. 12 | FOUNDATION_EXPORT double EnumerableVersionNumber; 13 | 14 | //! Project version string for Enumerable. 15 | FOUNDATION_EXPORT const unsigned char EnumerableVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /Enumerable/Enumerable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Enumerable.swift 3 | // Enumerable 4 | // 5 | // Created by Hirose.Yudai on 2017/08/28. 6 | // Copyright © 2017年 Hirose.Yudai. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public protocol Enumerable: RawRepresentable { 12 | static var enumerate: AnySequence { get } 13 | static var elements: [Self] { get } 14 | static var count: Int { get } 15 | static var startIndex: Int { get } 16 | } 17 | 18 | public extension Enumerable where RawValue == Int { 19 | public static var enumerate: AnySequence { 20 | return AnySequence { () -> AnyIterator in 21 | var i = startIndex 22 | return AnyIterator { () -> Self? in 23 | let element = Self(rawValue: i) 24 | i += 1 25 | return element 26 | } 27 | } 28 | } 29 | public static var elements: [Self] { 30 | return Array(enumerate) 31 | } 32 | 33 | public static var count: Int { 34 | return elements.count 35 | } 36 | 37 | public static var startIndex: Int { 38 | return 0 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Enumerable/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /EnumerableTests/EnumerableTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EnumerableTests.swift 3 | // EnumerableTests 4 | // 5 | // Created by Hirose.Yudai on 2017/08/28. 6 | // Copyright © 2017年 Hirose.Yudai. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | @testable import Enumerable 12 | fileprivate enum FromZero: Int, Enumerable { 13 | case zero = 0 14 | case one 15 | case two 16 | case three 17 | } 18 | 19 | fileprivate enum FromOne: Int { 20 | case one = 1 21 | case two 22 | case three 23 | } 24 | 25 | extension FromOne: Enumerable { 26 | public static var startIndex: Int { 27 | return 1 28 | } 29 | } 30 | 31 | class EnumerableTests: XCTestCase { 32 | 33 | override func setUp() { 34 | super.setUp() 35 | // Put setup code here. This method is called before the invocation of each test method in the class. 36 | } 37 | 38 | override func tearDown() { 39 | // Put teardown code here. This method is called after the invocation of each test method in the class. 40 | super.tearDown() 41 | } 42 | 43 | func testPerformanceExample() { 44 | // This is an example of a performance test case. 45 | self.measure { 46 | // Put the code you want to measure the time of here. 47 | } 48 | } 49 | 50 | func testFromZeroElements() { 51 | XCTAssertEqual(FromZero.elements.first!.rawValue, 0) 52 | XCTAssertEqual(FromZero.elements.last!.rawValue, 3) 53 | XCTAssertEqual(FromZero.elements.count, 4) 54 | XCTAssertEqual(FromZero.count, FromZero.elements.count) 55 | } 56 | 57 | func testFromOneElements() { 58 | XCTAssertEqual(FromOne.elements.first!.rawValue, 1) 59 | XCTAssertEqual(FromOne.elements.last!.rawValue, 3) 60 | XCTAssertEqual(FromOne.elements.count, 3) 61 | XCTAssertEqual(FromOne.count, FromOne.elements.count) 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /EnumerableTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Yudai hirose 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Enumerable 2 | 3 | **Enumrable** can get all the elements of `Enum`. 4 | 5 | # Usage 6 | Currently only support `Int`. 7 | 8 | Define `YourEnum`. 9 | ```swift 10 | enum YourEnum: Int, Enumerable { 11 | case one 12 | case two 13 | case three 14 | case four 15 | } 16 | ``` 17 | 18 | Get all elemnts. 19 | 20 | ```swift 21 | print(YourEnum.elements) // one, two, three, four 22 | print(YourEnum.count) // 4 23 | ``` 24 | 25 | It is particularly compatible with `TableView` and `CollectionView`. 26 | 27 | ```swift 28 | enum RowType: Int, Enumerable { 29 | case one 30 | case two 31 | case three 32 | case four 33 | } 34 | 35 | public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 36 | return RowType.count 37 | } 38 | 39 | 40 | public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 41 | guard let item = RowType(rawValue: indexPath.item) else { 42 | fatalError("out of section type: \(indexPath.section), model has sections: \(String(describing: model?.sections))") 43 | } 44 | switch item { 45 | case .one: 46 | case two: 47 | ... 48 | } 49 | ... 50 | } 51 | 52 | ``` 53 | 54 | # License 55 | 56 | Enumerable is available under the MIT license. See the LICENSE file for more info. 57 | 58 | --------------------------------------------------------------------------------