├── OC-Enum-String-Convertible-Example ├── OC-Enum-String-Convertible-Example.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── Teddy_Yann.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── Teddy_Yann.xcuserdatad │ │ └── xcschemes │ │ ├── OC-Enum-String-Convertible-Example.xcscheme │ │ └── xcschememanagement.plist ├── OC-Enum-String-Convertible-Example │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── EnumMarcos.h │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── OC-Enum-String-Convertible-ExampleTests │ ├── Info.plist │ └── OC_Enum_String_Convertible_ExampleTests.m └── OC-Enum-String-Convertible-ExampleUITests │ ├── Info.plist │ └── OC_Enum_String_Convertible_ExampleUITests.m └── README.md /OC-Enum-String-Convertible-Example/OC-Enum-String-Convertible-Example.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0B8AABC91F3A190700740716 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B8AABC81F3A190700740716 /* main.m */; }; 11 | 0B8AABCC1F3A190700740716 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B8AABCB1F3A190700740716 /* AppDelegate.m */; }; 12 | 0B8AABCF1F3A190700740716 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B8AABCE1F3A190700740716 /* ViewController.m */; }; 13 | 0B8AABD21F3A190700740716 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0B8AABD01F3A190700740716 /* Main.storyboard */; }; 14 | 0B8AABD41F3A190700740716 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0B8AABD31F3A190700740716 /* Assets.xcassets */; }; 15 | 0B8AABD71F3A190700740716 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0B8AABD51F3A190700740716 /* LaunchScreen.storyboard */; }; 16 | 0B8AABE21F3A190700740716 /* OC_Enum_String_Convertible_ExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B8AABE11F3A190700740716 /* OC_Enum_String_Convertible_ExampleTests.m */; }; 17 | 0B8AABED1F3A190700740716 /* OC_Enum_String_Convertible_ExampleUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B8AABEC1F3A190700740716 /* OC_Enum_String_Convertible_ExampleUITests.m */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | 0B8AABDE1F3A190700740716 /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = 0B8AABBC1F3A190700740716 /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = 0B8AABC31F3A190700740716; 26 | remoteInfo = "OC-Enum-String-Convertible-Example"; 27 | }; 28 | 0B8AABE91F3A190700740716 /* PBXContainerItemProxy */ = { 29 | isa = PBXContainerItemProxy; 30 | containerPortal = 0B8AABBC1F3A190700740716 /* Project object */; 31 | proxyType = 1; 32 | remoteGlobalIDString = 0B8AABC31F3A190700740716; 33 | remoteInfo = "OC-Enum-String-Convertible-Example"; 34 | }; 35 | /* End PBXContainerItemProxy section */ 36 | 37 | /* Begin PBXFileReference section */ 38 | 0B8AABC41F3A190700740716 /* OC-Enum-String-Convertible-Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "OC-Enum-String-Convertible-Example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 39 | 0B8AABC81F3A190700740716 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 40 | 0B8AABCA1F3A190700740716 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 41 | 0B8AABCB1F3A190700740716 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 42 | 0B8AABCD1F3A190700740716 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 43 | 0B8AABCE1F3A190700740716 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 44 | 0B8AABD11F3A190700740716 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 45 | 0B8AABD31F3A190700740716 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 46 | 0B8AABD61F3A190700740716 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 47 | 0B8AABD81F3A190700740716 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 48 | 0B8AABDD1F3A190700740716 /* OC-Enum-String-Convertible-ExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "OC-Enum-String-Convertible-ExampleTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 49 | 0B8AABE11F3A190700740716 /* OC_Enum_String_Convertible_ExampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OC_Enum_String_Convertible_ExampleTests.m; sourceTree = ""; }; 50 | 0B8AABE31F3A190700740716 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 51 | 0B8AABE81F3A190700740716 /* OC-Enum-String-Convertible-ExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "OC-Enum-String-Convertible-ExampleUITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 52 | 0B8AABEC1F3A190700740716 /* OC_Enum_String_Convertible_ExampleUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OC_Enum_String_Convertible_ExampleUITests.m; sourceTree = ""; }; 53 | 0B8AABEE1F3A190700740716 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 54 | 0B8AABFA1F3A191800740716 /* EnumMarcos.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EnumMarcos.h; sourceTree = ""; }; 55 | /* End PBXFileReference section */ 56 | 57 | /* Begin PBXFrameworksBuildPhase section */ 58 | 0B8AABC11F3A190700740716 /* Frameworks */ = { 59 | isa = PBXFrameworksBuildPhase; 60 | buildActionMask = 2147483647; 61 | files = ( 62 | ); 63 | runOnlyForDeploymentPostprocessing = 0; 64 | }; 65 | 0B8AABDA1F3A190700740716 /* Frameworks */ = { 66 | isa = PBXFrameworksBuildPhase; 67 | buildActionMask = 2147483647; 68 | files = ( 69 | ); 70 | runOnlyForDeploymentPostprocessing = 0; 71 | }; 72 | 0B8AABE51F3A190700740716 /* Frameworks */ = { 73 | isa = PBXFrameworksBuildPhase; 74 | buildActionMask = 2147483647; 75 | files = ( 76 | ); 77 | runOnlyForDeploymentPostprocessing = 0; 78 | }; 79 | /* End PBXFrameworksBuildPhase section */ 80 | 81 | /* Begin PBXGroup section */ 82 | 0B8AABBB1F3A190700740716 = { 83 | isa = PBXGroup; 84 | children = ( 85 | 0B8AABC61F3A190700740716 /* OC-Enum-String-Convertible-Example */, 86 | 0B8AABE01F3A190700740716 /* OC-Enum-String-Convertible-ExampleTests */, 87 | 0B8AABEB1F3A190700740716 /* OC-Enum-String-Convertible-ExampleUITests */, 88 | 0B8AABC51F3A190700740716 /* Products */, 89 | ); 90 | sourceTree = ""; 91 | }; 92 | 0B8AABC51F3A190700740716 /* Products */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | 0B8AABC41F3A190700740716 /* OC-Enum-String-Convertible-Example.app */, 96 | 0B8AABDD1F3A190700740716 /* OC-Enum-String-Convertible-ExampleTests.xctest */, 97 | 0B8AABE81F3A190700740716 /* OC-Enum-String-Convertible-ExampleUITests.xctest */, 98 | ); 99 | name = Products; 100 | sourceTree = ""; 101 | }; 102 | 0B8AABC61F3A190700740716 /* OC-Enum-String-Convertible-Example */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | 0B8AABCA1F3A190700740716 /* AppDelegate.h */, 106 | 0B8AABCB1F3A190700740716 /* AppDelegate.m */, 107 | 0B8AABCD1F3A190700740716 /* ViewController.h */, 108 | 0B8AABCE1F3A190700740716 /* ViewController.m */, 109 | 0B8AABFA1F3A191800740716 /* EnumMarcos.h */, 110 | 0B8AABD01F3A190700740716 /* Main.storyboard */, 111 | 0B8AABD31F3A190700740716 /* Assets.xcassets */, 112 | 0B8AABD51F3A190700740716 /* LaunchScreen.storyboard */, 113 | 0B8AABD81F3A190700740716 /* Info.plist */, 114 | 0B8AABC71F3A190700740716 /* Supporting Files */, 115 | ); 116 | path = "OC-Enum-String-Convertible-Example"; 117 | sourceTree = ""; 118 | }; 119 | 0B8AABC71F3A190700740716 /* Supporting Files */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | 0B8AABC81F3A190700740716 /* main.m */, 123 | ); 124 | name = "Supporting Files"; 125 | sourceTree = ""; 126 | }; 127 | 0B8AABE01F3A190700740716 /* OC-Enum-String-Convertible-ExampleTests */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | 0B8AABE11F3A190700740716 /* OC_Enum_String_Convertible_ExampleTests.m */, 131 | 0B8AABE31F3A190700740716 /* Info.plist */, 132 | ); 133 | path = "OC-Enum-String-Convertible-ExampleTests"; 134 | sourceTree = ""; 135 | }; 136 | 0B8AABEB1F3A190700740716 /* OC-Enum-String-Convertible-ExampleUITests */ = { 137 | isa = PBXGroup; 138 | children = ( 139 | 0B8AABEC1F3A190700740716 /* OC_Enum_String_Convertible_ExampleUITests.m */, 140 | 0B8AABEE1F3A190700740716 /* Info.plist */, 141 | ); 142 | path = "OC-Enum-String-Convertible-ExampleUITests"; 143 | sourceTree = ""; 144 | }; 145 | /* End PBXGroup section */ 146 | 147 | /* Begin PBXNativeTarget section */ 148 | 0B8AABC31F3A190700740716 /* OC-Enum-String-Convertible-Example */ = { 149 | isa = PBXNativeTarget; 150 | buildConfigurationList = 0B8AABF11F3A190700740716 /* Build configuration list for PBXNativeTarget "OC-Enum-String-Convertible-Example" */; 151 | buildPhases = ( 152 | 0B8AABC01F3A190700740716 /* Sources */, 153 | 0B8AABC11F3A190700740716 /* Frameworks */, 154 | 0B8AABC21F3A190700740716 /* Resources */, 155 | ); 156 | buildRules = ( 157 | ); 158 | dependencies = ( 159 | ); 160 | name = "OC-Enum-String-Convertible-Example"; 161 | productName = "OC-Enum-String-Convertible-Example"; 162 | productReference = 0B8AABC41F3A190700740716 /* OC-Enum-String-Convertible-Example.app */; 163 | productType = "com.apple.product-type.application"; 164 | }; 165 | 0B8AABDC1F3A190700740716 /* OC-Enum-String-Convertible-ExampleTests */ = { 166 | isa = PBXNativeTarget; 167 | buildConfigurationList = 0B8AABF41F3A190700740716 /* Build configuration list for PBXNativeTarget "OC-Enum-String-Convertible-ExampleTests" */; 168 | buildPhases = ( 169 | 0B8AABD91F3A190700740716 /* Sources */, 170 | 0B8AABDA1F3A190700740716 /* Frameworks */, 171 | 0B8AABDB1F3A190700740716 /* Resources */, 172 | ); 173 | buildRules = ( 174 | ); 175 | dependencies = ( 176 | 0B8AABDF1F3A190700740716 /* PBXTargetDependency */, 177 | ); 178 | name = "OC-Enum-String-Convertible-ExampleTests"; 179 | productName = "OC-Enum-String-Convertible-ExampleTests"; 180 | productReference = 0B8AABDD1F3A190700740716 /* OC-Enum-String-Convertible-ExampleTests.xctest */; 181 | productType = "com.apple.product-type.bundle.unit-test"; 182 | }; 183 | 0B8AABE71F3A190700740716 /* OC-Enum-String-Convertible-ExampleUITests */ = { 184 | isa = PBXNativeTarget; 185 | buildConfigurationList = 0B8AABF71F3A190700740716 /* Build configuration list for PBXNativeTarget "OC-Enum-String-Convertible-ExampleUITests" */; 186 | buildPhases = ( 187 | 0B8AABE41F3A190700740716 /* Sources */, 188 | 0B8AABE51F3A190700740716 /* Frameworks */, 189 | 0B8AABE61F3A190700740716 /* Resources */, 190 | ); 191 | buildRules = ( 192 | ); 193 | dependencies = ( 194 | 0B8AABEA1F3A190700740716 /* PBXTargetDependency */, 195 | ); 196 | name = "OC-Enum-String-Convertible-ExampleUITests"; 197 | productName = "OC-Enum-String-Convertible-ExampleUITests"; 198 | productReference = 0B8AABE81F3A190700740716 /* OC-Enum-String-Convertible-ExampleUITests.xctest */; 199 | productType = "com.apple.product-type.bundle.ui-testing"; 200 | }; 201 | /* End PBXNativeTarget section */ 202 | 203 | /* Begin PBXProject section */ 204 | 0B8AABBC1F3A190700740716 /* Project object */ = { 205 | isa = PBXProject; 206 | attributes = { 207 | LastUpgradeCheck = 0830; 208 | ORGANIZATIONNAME = RendezvousAuParadis; 209 | TargetAttributes = { 210 | 0B8AABC31F3A190700740716 = { 211 | CreatedOnToolsVersion = 8.3.3; 212 | DevelopmentTeam = QX885U799E; 213 | ProvisioningStyle = Automatic; 214 | }; 215 | 0B8AABDC1F3A190700740716 = { 216 | CreatedOnToolsVersion = 8.3.3; 217 | DevelopmentTeam = QX885U799E; 218 | ProvisioningStyle = Automatic; 219 | TestTargetID = 0B8AABC31F3A190700740716; 220 | }; 221 | 0B8AABE71F3A190700740716 = { 222 | CreatedOnToolsVersion = 8.3.3; 223 | DevelopmentTeam = QX885U799E; 224 | ProvisioningStyle = Automatic; 225 | TestTargetID = 0B8AABC31F3A190700740716; 226 | }; 227 | }; 228 | }; 229 | buildConfigurationList = 0B8AABBF1F3A190700740716 /* Build configuration list for PBXProject "OC-Enum-String-Convertible-Example" */; 230 | compatibilityVersion = "Xcode 3.2"; 231 | developmentRegion = English; 232 | hasScannedForEncodings = 0; 233 | knownRegions = ( 234 | en, 235 | Base, 236 | ); 237 | mainGroup = 0B8AABBB1F3A190700740716; 238 | productRefGroup = 0B8AABC51F3A190700740716 /* Products */; 239 | projectDirPath = ""; 240 | projectRoot = ""; 241 | targets = ( 242 | 0B8AABC31F3A190700740716 /* OC-Enum-String-Convertible-Example */, 243 | 0B8AABDC1F3A190700740716 /* OC-Enum-String-Convertible-ExampleTests */, 244 | 0B8AABE71F3A190700740716 /* OC-Enum-String-Convertible-ExampleUITests */, 245 | ); 246 | }; 247 | /* End PBXProject section */ 248 | 249 | /* Begin PBXResourcesBuildPhase section */ 250 | 0B8AABC21F3A190700740716 /* Resources */ = { 251 | isa = PBXResourcesBuildPhase; 252 | buildActionMask = 2147483647; 253 | files = ( 254 | 0B8AABD71F3A190700740716 /* LaunchScreen.storyboard in Resources */, 255 | 0B8AABD41F3A190700740716 /* Assets.xcassets in Resources */, 256 | 0B8AABD21F3A190700740716 /* Main.storyboard in Resources */, 257 | ); 258 | runOnlyForDeploymentPostprocessing = 0; 259 | }; 260 | 0B8AABDB1F3A190700740716 /* Resources */ = { 261 | isa = PBXResourcesBuildPhase; 262 | buildActionMask = 2147483647; 263 | files = ( 264 | ); 265 | runOnlyForDeploymentPostprocessing = 0; 266 | }; 267 | 0B8AABE61F3A190700740716 /* Resources */ = { 268 | isa = PBXResourcesBuildPhase; 269 | buildActionMask = 2147483647; 270 | files = ( 271 | ); 272 | runOnlyForDeploymentPostprocessing = 0; 273 | }; 274 | /* End PBXResourcesBuildPhase section */ 275 | 276 | /* Begin PBXSourcesBuildPhase section */ 277 | 0B8AABC01F3A190700740716 /* Sources */ = { 278 | isa = PBXSourcesBuildPhase; 279 | buildActionMask = 2147483647; 280 | files = ( 281 | 0B8AABCF1F3A190700740716 /* ViewController.m in Sources */, 282 | 0B8AABCC1F3A190700740716 /* AppDelegate.m in Sources */, 283 | 0B8AABC91F3A190700740716 /* main.m in Sources */, 284 | ); 285 | runOnlyForDeploymentPostprocessing = 0; 286 | }; 287 | 0B8AABD91F3A190700740716 /* Sources */ = { 288 | isa = PBXSourcesBuildPhase; 289 | buildActionMask = 2147483647; 290 | files = ( 291 | 0B8AABE21F3A190700740716 /* OC_Enum_String_Convertible_ExampleTests.m in Sources */, 292 | ); 293 | runOnlyForDeploymentPostprocessing = 0; 294 | }; 295 | 0B8AABE41F3A190700740716 /* Sources */ = { 296 | isa = PBXSourcesBuildPhase; 297 | buildActionMask = 2147483647; 298 | files = ( 299 | 0B8AABED1F3A190700740716 /* OC_Enum_String_Convertible_ExampleUITests.m in Sources */, 300 | ); 301 | runOnlyForDeploymentPostprocessing = 0; 302 | }; 303 | /* End PBXSourcesBuildPhase section */ 304 | 305 | /* Begin PBXTargetDependency section */ 306 | 0B8AABDF1F3A190700740716 /* PBXTargetDependency */ = { 307 | isa = PBXTargetDependency; 308 | target = 0B8AABC31F3A190700740716 /* OC-Enum-String-Convertible-Example */; 309 | targetProxy = 0B8AABDE1F3A190700740716 /* PBXContainerItemProxy */; 310 | }; 311 | 0B8AABEA1F3A190700740716 /* PBXTargetDependency */ = { 312 | isa = PBXTargetDependency; 313 | target = 0B8AABC31F3A190700740716 /* OC-Enum-String-Convertible-Example */; 314 | targetProxy = 0B8AABE91F3A190700740716 /* PBXContainerItemProxy */; 315 | }; 316 | /* End PBXTargetDependency section */ 317 | 318 | /* Begin PBXVariantGroup section */ 319 | 0B8AABD01F3A190700740716 /* Main.storyboard */ = { 320 | isa = PBXVariantGroup; 321 | children = ( 322 | 0B8AABD11F3A190700740716 /* Base */, 323 | ); 324 | name = Main.storyboard; 325 | sourceTree = ""; 326 | }; 327 | 0B8AABD51F3A190700740716 /* LaunchScreen.storyboard */ = { 328 | isa = PBXVariantGroup; 329 | children = ( 330 | 0B8AABD61F3A190700740716 /* Base */, 331 | ); 332 | name = LaunchScreen.storyboard; 333 | sourceTree = ""; 334 | }; 335 | /* End PBXVariantGroup section */ 336 | 337 | /* Begin XCBuildConfiguration section */ 338 | 0B8AABEF1F3A190700740716 /* Debug */ = { 339 | isa = XCBuildConfiguration; 340 | buildSettings = { 341 | ALWAYS_SEARCH_USER_PATHS = NO; 342 | CLANG_ANALYZER_NONNULL = YES; 343 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 344 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 345 | CLANG_CXX_LIBRARY = "libc++"; 346 | CLANG_ENABLE_MODULES = YES; 347 | CLANG_ENABLE_OBJC_ARC = YES; 348 | CLANG_WARN_BOOL_CONVERSION = YES; 349 | CLANG_WARN_CONSTANT_CONVERSION = YES; 350 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 351 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 352 | CLANG_WARN_EMPTY_BODY = YES; 353 | CLANG_WARN_ENUM_CONVERSION = YES; 354 | CLANG_WARN_INFINITE_RECURSION = YES; 355 | CLANG_WARN_INT_CONVERSION = YES; 356 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 357 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 358 | CLANG_WARN_UNREACHABLE_CODE = YES; 359 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 360 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 361 | COPY_PHASE_STRIP = NO; 362 | DEBUG_INFORMATION_FORMAT = dwarf; 363 | ENABLE_STRICT_OBJC_MSGSEND = YES; 364 | ENABLE_TESTABILITY = YES; 365 | GCC_C_LANGUAGE_STANDARD = gnu99; 366 | GCC_DYNAMIC_NO_PIC = NO; 367 | GCC_NO_COMMON_BLOCKS = YES; 368 | GCC_OPTIMIZATION_LEVEL = 0; 369 | GCC_PREPROCESSOR_DEFINITIONS = ( 370 | "DEBUG=1", 371 | "$(inherited)", 372 | ); 373 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 374 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 375 | GCC_WARN_UNDECLARED_SELECTOR = YES; 376 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 377 | GCC_WARN_UNUSED_FUNCTION = YES; 378 | GCC_WARN_UNUSED_VARIABLE = YES; 379 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 380 | MTL_ENABLE_DEBUG_INFO = YES; 381 | ONLY_ACTIVE_ARCH = YES; 382 | SDKROOT = iphoneos; 383 | TARGETED_DEVICE_FAMILY = "1,2"; 384 | }; 385 | name = Debug; 386 | }; 387 | 0B8AABF01F3A190700740716 /* Release */ = { 388 | isa = XCBuildConfiguration; 389 | buildSettings = { 390 | ALWAYS_SEARCH_USER_PATHS = NO; 391 | CLANG_ANALYZER_NONNULL = YES; 392 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 393 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 394 | CLANG_CXX_LIBRARY = "libc++"; 395 | CLANG_ENABLE_MODULES = YES; 396 | CLANG_ENABLE_OBJC_ARC = YES; 397 | CLANG_WARN_BOOL_CONVERSION = YES; 398 | CLANG_WARN_CONSTANT_CONVERSION = YES; 399 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 400 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 401 | CLANG_WARN_EMPTY_BODY = YES; 402 | CLANG_WARN_ENUM_CONVERSION = YES; 403 | CLANG_WARN_INFINITE_RECURSION = YES; 404 | CLANG_WARN_INT_CONVERSION = YES; 405 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 406 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 407 | CLANG_WARN_UNREACHABLE_CODE = YES; 408 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 409 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 410 | COPY_PHASE_STRIP = NO; 411 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 412 | ENABLE_NS_ASSERTIONS = NO; 413 | ENABLE_STRICT_OBJC_MSGSEND = YES; 414 | GCC_C_LANGUAGE_STANDARD = gnu99; 415 | GCC_NO_COMMON_BLOCKS = YES; 416 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 417 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 418 | GCC_WARN_UNDECLARED_SELECTOR = YES; 419 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 420 | GCC_WARN_UNUSED_FUNCTION = YES; 421 | GCC_WARN_UNUSED_VARIABLE = YES; 422 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 423 | MTL_ENABLE_DEBUG_INFO = NO; 424 | SDKROOT = iphoneos; 425 | TARGETED_DEVICE_FAMILY = "1,2"; 426 | VALIDATE_PRODUCT = YES; 427 | }; 428 | name = Release; 429 | }; 430 | 0B8AABF21F3A190700740716 /* Debug */ = { 431 | isa = XCBuildConfiguration; 432 | buildSettings = { 433 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 434 | DEVELOPMENT_TEAM = QX885U799E; 435 | INFOPLIST_FILE = "OC-Enum-String-Convertible-Example/Info.plist"; 436 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 437 | PRODUCT_BUNDLE_IDENTIFIER = "com.rendezvousauparadis.OC-Enum-String-Convertible-Example"; 438 | PRODUCT_NAME = "$(TARGET_NAME)"; 439 | }; 440 | name = Debug; 441 | }; 442 | 0B8AABF31F3A190700740716 /* Release */ = { 443 | isa = XCBuildConfiguration; 444 | buildSettings = { 445 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 446 | DEVELOPMENT_TEAM = QX885U799E; 447 | INFOPLIST_FILE = "OC-Enum-String-Convertible-Example/Info.plist"; 448 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 449 | PRODUCT_BUNDLE_IDENTIFIER = "com.rendezvousauparadis.OC-Enum-String-Convertible-Example"; 450 | PRODUCT_NAME = "$(TARGET_NAME)"; 451 | }; 452 | name = Release; 453 | }; 454 | 0B8AABF51F3A190700740716 /* Debug */ = { 455 | isa = XCBuildConfiguration; 456 | buildSettings = { 457 | BUNDLE_LOADER = "$(TEST_HOST)"; 458 | DEVELOPMENT_TEAM = QX885U799E; 459 | INFOPLIST_FILE = "OC-Enum-String-Convertible-ExampleTests/Info.plist"; 460 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 461 | PRODUCT_BUNDLE_IDENTIFIER = "com.rendezvousauparadis.OC-Enum-String-Convertible-ExampleTests"; 462 | PRODUCT_NAME = "$(TARGET_NAME)"; 463 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/OC-Enum-String-Convertible-Example.app/OC-Enum-String-Convertible-Example"; 464 | }; 465 | name = Debug; 466 | }; 467 | 0B8AABF61F3A190700740716 /* Release */ = { 468 | isa = XCBuildConfiguration; 469 | buildSettings = { 470 | BUNDLE_LOADER = "$(TEST_HOST)"; 471 | DEVELOPMENT_TEAM = QX885U799E; 472 | INFOPLIST_FILE = "OC-Enum-String-Convertible-ExampleTests/Info.plist"; 473 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 474 | PRODUCT_BUNDLE_IDENTIFIER = "com.rendezvousauparadis.OC-Enum-String-Convertible-ExampleTests"; 475 | PRODUCT_NAME = "$(TARGET_NAME)"; 476 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/OC-Enum-String-Convertible-Example.app/OC-Enum-String-Convertible-Example"; 477 | }; 478 | name = Release; 479 | }; 480 | 0B8AABF81F3A190700740716 /* Debug */ = { 481 | isa = XCBuildConfiguration; 482 | buildSettings = { 483 | DEVELOPMENT_TEAM = QX885U799E; 484 | INFOPLIST_FILE = "OC-Enum-String-Convertible-ExampleUITests/Info.plist"; 485 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 486 | PRODUCT_BUNDLE_IDENTIFIER = "com.rendezvousauparadis.OC-Enum-String-Convertible-ExampleUITests"; 487 | PRODUCT_NAME = "$(TARGET_NAME)"; 488 | TEST_TARGET_NAME = "OC-Enum-String-Convertible-Example"; 489 | }; 490 | name = Debug; 491 | }; 492 | 0B8AABF91F3A190700740716 /* Release */ = { 493 | isa = XCBuildConfiguration; 494 | buildSettings = { 495 | DEVELOPMENT_TEAM = QX885U799E; 496 | INFOPLIST_FILE = "OC-Enum-String-Convertible-ExampleUITests/Info.plist"; 497 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 498 | PRODUCT_BUNDLE_IDENTIFIER = "com.rendezvousauparadis.OC-Enum-String-Convertible-ExampleUITests"; 499 | PRODUCT_NAME = "$(TARGET_NAME)"; 500 | TEST_TARGET_NAME = "OC-Enum-String-Convertible-Example"; 501 | }; 502 | name = Release; 503 | }; 504 | /* End XCBuildConfiguration section */ 505 | 506 | /* Begin XCConfigurationList section */ 507 | 0B8AABBF1F3A190700740716 /* Build configuration list for PBXProject "OC-Enum-String-Convertible-Example" */ = { 508 | isa = XCConfigurationList; 509 | buildConfigurations = ( 510 | 0B8AABEF1F3A190700740716 /* Debug */, 511 | 0B8AABF01F3A190700740716 /* Release */, 512 | ); 513 | defaultConfigurationIsVisible = 0; 514 | defaultConfigurationName = Release; 515 | }; 516 | 0B8AABF11F3A190700740716 /* Build configuration list for PBXNativeTarget "OC-Enum-String-Convertible-Example" */ = { 517 | isa = XCConfigurationList; 518 | buildConfigurations = ( 519 | 0B8AABF21F3A190700740716 /* Debug */, 520 | 0B8AABF31F3A190700740716 /* Release */, 521 | ); 522 | defaultConfigurationIsVisible = 0; 523 | }; 524 | 0B8AABF41F3A190700740716 /* Build configuration list for PBXNativeTarget "OC-Enum-String-Convertible-ExampleTests" */ = { 525 | isa = XCConfigurationList; 526 | buildConfigurations = ( 527 | 0B8AABF51F3A190700740716 /* Debug */, 528 | 0B8AABF61F3A190700740716 /* Release */, 529 | ); 530 | defaultConfigurationIsVisible = 0; 531 | }; 532 | 0B8AABF71F3A190700740716 /* Build configuration list for PBXNativeTarget "OC-Enum-String-Convertible-ExampleUITests" */ = { 533 | isa = XCConfigurationList; 534 | buildConfigurations = ( 535 | 0B8AABF81F3A190700740716 /* Debug */, 536 | 0B8AABF91F3A190700740716 /* Release */, 537 | ); 538 | defaultConfigurationIsVisible = 0; 539 | }; 540 | /* End XCConfigurationList section */ 541 | }; 542 | rootObject = 0B8AABBC1F3A190700740716 /* Project object */; 543 | } 544 | -------------------------------------------------------------------------------- /OC-Enum-String-Convertible-Example/OC-Enum-String-Convertible-Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /OC-Enum-String-Convertible-Example/OC-Enum-String-Convertible-Example.xcodeproj/project.xcworkspace/xcuserdata/Teddy_Yann.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yannmm/OC-Enum-String-Convertible-Example/c25ee7f4841d1d3b5068ce7ab1ba4f74ee122e0a/OC-Enum-String-Convertible-Example/OC-Enum-String-Convertible-Example.xcodeproj/project.xcworkspace/xcuserdata/Teddy_Yann.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /OC-Enum-String-Convertible-Example/OC-Enum-String-Convertible-Example.xcodeproj/xcuserdata/Teddy_Yann.xcuserdatad/xcschemes/OC-Enum-String-Convertible-Example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /OC-Enum-String-Convertible-Example/OC-Enum-String-Convertible-Example.xcodeproj/xcuserdata/Teddy_Yann.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | OC-Enum-String-Convertible-Example.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 0B8AABC31F3A190700740716 16 | 17 | primary 18 | 19 | 20 | 0B8AABDC1F3A190700740716 21 | 22 | primary 23 | 24 | 25 | 0B8AABE71F3A190700740716 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /OC-Enum-String-Convertible-Example/OC-Enum-String-Convertible-Example/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // OC-Enum-String-Convertible-Example 4 | // 5 | // Created by 闫萌 on 17/8/9. 6 | // Copyright © 2017 RendezvousAuParadis. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /OC-Enum-String-Convertible-Example/OC-Enum-String-Convertible-Example/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // OC-Enum-String-Convertible-Example 4 | // 5 | // Created by 闫萌 on 17/8/9. 6 | // Copyright © 2017 RendezvousAuParadis. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /OC-Enum-String-Convertible-Example/OC-Enum-String-Convertible-Example/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /OC-Enum-String-Convertible-Example/OC-Enum-String-Convertible-Example/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /OC-Enum-String-Convertible-Example/OC-Enum-String-Convertible-Example/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /OC-Enum-String-Convertible-Example/OC-Enum-String-Convertible-Example/EnumMarcos.h: -------------------------------------------------------------------------------- 1 | // 2 | // EnumMarcos.h 3 | // OC-Enum-String-Convertible-Example 4 | // 5 | // Created by 闫萌 on 17/8/9. 6 | // Copyright © 2017 RendezvousAuParadis. All rights reserved. 7 | // 8 | 9 | #ifndef EnumMarcos_h 10 | #define EnumMarcos_h 11 | 12 | /* 13 | Reference: http://stackoverflow.com/a/202511 14 | For how to use, see https://github.com/Yannmm/OC-Enum-String-Convertible-Example 15 | */ 16 | 17 | #pragma mark - Enum Factory Macros 18 | 19 | /** 20 | 定义一个枚举case 21 | */ 22 | #define ENUM_VALUE(name, assign) name assign, 23 | 24 | /** 25 | 展开后是一个switch语句的case,返回一个字符串 26 | */ 27 | #define ENUM_CASE(name, assign) case name: return @#name; 28 | 29 | /** 30 | 展开后通过比较字符串,返回相应枚举case 31 | */ 32 | #define ENUM_STRCMP(name, assign) if ([string isEqualToString:@#name]) return name; 33 | 34 | /** 35 | 定义枚举,声明反射函数; 36 | */ 37 | #define DECLARE_ENUM(EnumType, ENUM_DEF) \ 38 | typedef NS_ENUM(NSInteger, EnumType) { \ 39 | ENUM_DEF(ENUM_VALUE) \ 40 | }; \ 41 | NSString *NSStringFrom##EnumType(EnumType value); \ 42 | EnumType EnumType##FromNSString(NSString *string); \ 43 | 44 | /** 45 | 实现实现函数; 46 | */ 47 | #define DEFINE_ENUM(EnumType, ENUM_DEF) \ 48 | NSString *NSStringFrom##EnumType(EnumType value) \ 49 | { \ 50 | switch(value) \ 51 | { \ 52 | ENUM_DEF(ENUM_CASE) \ 53 | default: return @""; \ 54 | } \ 55 | } \ 56 | EnumType EnumType##FromNSString(NSString *string) \ 57 | { \ 58 | ENUM_DEF(ENUM_STRCMP) \ 59 | return (EnumType)0; \ 60 | } 61 | 62 | 63 | #endif /* EnumMarcos_h */ 64 | -------------------------------------------------------------------------------- /OC-Enum-String-Convertible-Example/OC-Enum-String-Convertible-Example/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 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /OC-Enum-String-Convertible-Example/OC-Enum-String-Convertible-Example/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // OC-Enum-String-Convertible-Example 4 | // 5 | // Created by 闫萌 on 17/8/9. 6 | // Copyright © 2017 RendezvousAuParadis. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "EnumMarcos.h" 12 | 13 | #define RAP_DIRECTION(XX) \ 14 | XX(RAPDirectionEast, ) \ 15 | XX(RAPDirectionSouth, ) \ 16 | XX(RAPDirectionWest, = 50) \ 17 | XX(RAPDirectionNorth, = 100) \ 18 | 19 | DECLARE_ENUM(RAPDirection, RAP_DIRECTION) 20 | 21 | @interface ViewController : UIViewController 22 | 23 | 24 | @end 25 | 26 | -------------------------------------------------------------------------------- /OC-Enum-String-Convertible-Example/OC-Enum-String-Convertible-Example/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // OC-Enum-String-Convertible-Example 4 | // 5 | // Created by 闫萌 on 17/8/9. 6 | // Copyright © 2017 RendezvousAuParadis. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | DEFINE_ENUM(RAPDirection, RAP_DIRECTION) 12 | 13 | @interface ViewController () 14 | 15 | @end 16 | 17 | @implementation ViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | // Do any additional setup after loading the view, typically from a nib. 22 | 23 | NSString *str = NSStringFromRAPDirection(RAPDirectionEast); 24 | NSLog(@"RAPDirectionEast has case name: %@", str); 25 | 26 | 27 | RAPDirection dir = RAPDirectionFromNSString(@"RAPDirectionNorth"); 28 | NSLog(@"RAPDirectionNorth has case value: %zd", dir); 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /OC-Enum-String-Convertible-Example/OC-Enum-String-Convertible-Example/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // OC-Enum-String-Convertible-Example 4 | // 5 | // Created by 闫萌 on 17/8/9. 6 | // Copyright © 2017 RendezvousAuParadis. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /OC-Enum-String-Convertible-Example/OC-Enum-String-Convertible-ExampleTests/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 | -------------------------------------------------------------------------------- /OC-Enum-String-Convertible-Example/OC-Enum-String-Convertible-ExampleTests/OC_Enum_String_Convertible_ExampleTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // OC_Enum_String_Convertible_ExampleTests.m 3 | // OC-Enum-String-Convertible-ExampleTests 4 | // 5 | // Created by 闫萌 on 17/8/9. 6 | // Copyright © 2017 RendezvousAuParadis. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface OC_Enum_String_Convertible_ExampleTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation OC_Enum_String_Convertible_ExampleTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /OC-Enum-String-Convertible-Example/OC-Enum-String-Convertible-ExampleUITests/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 | -------------------------------------------------------------------------------- /OC-Enum-String-Convertible-Example/OC-Enum-String-Convertible-ExampleUITests/OC_Enum_String_Convertible_ExampleUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // OC_Enum_String_Convertible_ExampleUITests.m 3 | // OC-Enum-String-Convertible-ExampleUITests 4 | // 5 | // Created by 闫萌 on 17/8/9. 6 | // Copyright © 2017 RendezvousAuParadis. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface OC_Enum_String_Convertible_ExampleUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation OC_Enum_String_Convertible_ExampleUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OC枚举值到字符串转换 2 | 3 | 4 | >Swift枚举类型引入了Raw Value的概念,每个枚举case的Raw Value可以是其case name。假设有case king,则king.rawValue = "king"。相比之下OC枚举类型就弱爆了,只能绑定整数;要"反射"自己的case name,必须手动实现反射函数。不过,宏替换可以在一定程度上帮助我们自动实现。 5 | > 6 | > 7 | >本文基于[Easy way to use variables of enum types as string in C? 8 | ](https://stackoverflow.com/questions/147267/easy-way-to-use-variables-of-enum-types-as-string-in-c/202511#202511),是笔者无意间看到的。短短几十行宏代码,看了好大一会儿也不知所以然,不得不重新捧起K&R复习Marcos;晚上回家接着细细研读,不禁感叹:竟然还有这种操作! 9 | 10 | --- 11 | 12 | ## A. 使用 13 | 14 | 这套宏的用法分为两步: 15 | 16 | ### A.1 在.h文件中定义枚举,声明反射函数 17 | 18 | ```c 19 | // M1 20 | #define RAP_DIRECTION(XX) \ 21 | XX(RAPDirectionEast, ) \ 22 | XX(RAPDirectionSouth, ) \ 23 | XX(RAPDirectionWest, = 50) \ 24 | XX(RAPDirectionNorth, = 100) \ 25 | 26 | // M2 27 | DECLARE_ENUM(RAPDirection, RAP_DIRECTION) 28 | ``` 29 | 30 | - M1生成多个枚举case。枚举case的定义格式为XX(name, assign),name即case name;assign即对应整数值,格式必须为`= Integer`,不填表示使用默认值; 31 | - M2定义枚举,声明反射函数。反射函数的有两个: 32 | - 根据case获取case name:NSStringFromRAPDirection(RAPDirection value); 33 | - 根据case name获取case:RAPDirectionFromNSString(NSString *string); 34 | 35 | ### A.2 在.m文件中实现反射函数 36 | 37 | ```c 38 | DEFINE_ENUM(RAPDirection, RAP_DIRECTION) 39 | ``` 40 | - RAPDirection和RAP_DIRECTION要与.h中的宏对应。RAPDirection是枚举类型名称,RAP_DIRECTION是宏,展开后变成多个枚举case。 41 | 42 | ### A.3 例子 43 | 44 | 1. 在任意.h文件中定义枚举,声明反射函数: 45 | 46 | ```c 47 | #import "EnumMarcos.h" 48 | 49 | #define RAP_DIRECTION(XX) \ 50 | XX(RAPDirectionEast, ) \ 51 | XX(RAPDirectionSouth, ) \ 52 | XX(RAPDirectionWest, = 50) \ 53 | XX(RAPDirectionNorth, = 100) \ 54 | 55 | DECLARE_ENUM(RAPDirection, RAP_DIRECTION) 56 | ``` 57 | 58 | 2. 在相应的.m文件中实现反射函数: 59 | 60 | ```c 61 | DEFINE_ENUM(RAPDirection, RAP_DIRECTION) 62 | ``` 63 | 64 | 3. 尝试使用: 65 | 66 | ```c 67 | NSString *str = NSStringFromRAPDirection(RAPDirectionEast); 68 | NSLog(@"RAPDirectionEast has case name: %@", str); 69 | 70 | 71 | RAPDirection dir = RAPDirectionFromNSString(@"RAPDirectionNorth"); 72 | NSLog(@"RAPDirectionNorth has case value: %zd", dir); 73 | ``` 74 | 75 | 输出结果: 76 | 77 | ``` 78 | RAPDirectionEast has case name: RAPDirectionEast 79 | RAPDirectionNorth has case value: 100 80 | ``` 81 | 82 | 83 | 84 | ## B. 实现 85 | 86 | ### B.1 DECLARE_ENUM(EnumType, ENUM_DEF) 87 | 88 | ```c 89 | 90 | #define DECLARE_ENUM(EnumType, ENUM_DEF) \ 91 | typedef NS_ENUM(NSInteger, EnumType) { \ 92 | ENUM_DEF(ENUM_VALUE) \ 93 | }; \ 94 | NSString *NSStringFrom##EnumType(EnumType value); \ 95 | EnumType EnumType##FromNSString(NSString *string); \ 96 | ``` 97 | 98 | - 第1行:EnumType是枚举类型;ENUM_DEF是替换宏,格式为XX(name, assign),同同ENUM_VALUE,ENUM_CASE以及ENUM_STRCMP的形式一致; 99 | - 第2行:Apple式的枚举定义风格; 100 | - 第3行:ENUM_DEF(ENUM_VALUE)展开为多个ENUM_VALUE,进一步展开为多个`name assign,`的形式;(ENUM_VALUE的分析在下面) 101 | - 第5,6行:声明反射函数。##的用法不再赘述; 102 | 103 | #### B.1.1 ENUM_VALUE(name, assign) 104 | 105 | ```c 106 | #define ENUM_VALUE(name, assign) name assign, 107 | ``` 108 | 109 | - 定义一个枚举case:name即case name;assign即整数值,格式为`= Interfer`。 110 | - 例如:ENUM_VALUE(King, = 13);展开后:`King = 13,`,注意最后的逗号不可获取。 111 | 112 | 113 | ### B.2 DEFINE_ENUM(EnumType, ENUM_DEF) 114 | 115 | ```c 116 | #define DEFINE_ENUM(EnumType, ENUM_DEF) \ 117 | NSString *NSStringFrom##EnumType(EnumType value) \ 118 | { \ 119 | switch(value) \ 120 | { \ 121 | ENUM_DEF(ENUM_CASE) \ 122 | default: return @""; \ 123 | } \ 124 | } \ 125 | EnumType EnumType##FromNSString(NSString *string) \ 126 | { \ 127 | ENUM_DEF(ENUM_STRCMP) \ 128 | return (EnumType)0; \ 129 | } 130 | ``` 131 | 132 | - 第7行:如果找不到对应case name,返回@""; 133 | - 第8行:如果找不到对应case,则返回0; 134 | - 其他同DECLARE_ENUM(EnumType, ENUM_DEF); 135 | 136 | #### B.2.1 ENUM_CASE(name, assign) 137 | 138 | ```c 139 | #define ENUM_CASE(name, assign) case name: return @#name; 140 | ``` 141 | 142 | - 展开后是一个switch语句的case,返回一个字符串;#name表示"name",所以@#name表示@"name",OC字符串。 143 | - 例如:ENUM_CASE(King, 13),展开后:case King: return @"King"; 144 | 145 | #### B.2.1 ENUM_STRCMP(name, assign) 146 | 147 | ```c 148 | #define ENUM_STRCMP(name, assign) if ([string isEqualToString:@#name]) return name; 149 | ``` 150 | 151 | - 展开后通过比较字符串,返回相应枚举case; 152 | - string是函数`EnumType##FromNSString`的参数,展开时自动填入; 153 | - 例如:ENUM_STRCMP(King, 13),展开后:if ([string isEqualToString:@"King"]) return King; 154 | 155 | 156 | ## 参考资料 157 | 158 | 1. [示例代码](https://github.com/Yannmm/OC-Enum-String-Convertible-Example) 159 | 2. [Easy way to use variables of enum types as string in C? 160 | ](https://stackoverflow.com/questions/147267/easy-way-to-use-variables-of-enum-types-as-string-in-c/202511#202511) 161 | 162 | --------------------------------------------------------------------------------