I'm trying to convert iOS error codes to String in Swift 2 (XCode 7.2). But converting to String returns the type name instead of the value name for system enums.
This is what I'm trying:
import CoreLocation
import EventKit
let clError = CLError.LocationUnknown
let clErrorString = "\(clError)"
// EXPECTED: 'LocationUnknown'. OBTAINED: 'CLError'
let ekError = EKErrorCode.CalendarIsImmutable
let ekErrorString = "\(ekError)"
// EXPECTED: 'CalendarIsImmutable'. OBTAINED: 'EKErrorCode'
But with enums declared in Swift, this works as expected:
enum _EKErrorCode : Int {
case CalendarIsImmutable
}
let _ekError = _EKErrorCode.CalendarIsImmutable
let _ekErrorString = "\(_ekError)"
// EXPECTED: 'CalendarIsImmutable'. OBTAINED: 'CalendarIsImmutable'
I'm trying to avoid a Switch-Case with all posible enum values, or extending system types adding a custom description.