Skip to content

Instantly share code, notes, and snippets.

@3lvis
Last active August 29, 2015 14:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 3lvis/113bcf23dc8255f09712 to your computer and use it in GitHub Desktop.
Save 3lvis/113bcf23dc8255f09712 to your computer and use it in GitHub Desktop.
Enums in Swift and Objective-C
// Swift
enum StatusCode: Int {
case Unknown = 0
case Unauthorized = 401
case Forbidden = 403
case InternalServerError = 500
case ServiceUnavailable = 503
}
// Objective-C
typedef NS_OPTIONS(NSInteger, NetworkingStatusCode) {
NetworkingStatusCodeUnknown = 0,
NetworkingStatusCodeUnauthorized = 401,
NetworkingStatusCodeForbidden = 403,
NetworkingStatusCodeInternalServerError = 500,
NetworkingStatusCodeServiceUnavailable = 503
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment