I would like to introduce a swift toolkit enhancement that would adhere AGS enums to the swift CustomStringConvertible and CustomDebugStringConvertible protocols.
This enhancement will allow someone to either:
- Help display to a user a stringified status
- Display to a developer a stringified debug status in the debug console
This will allow a developer to more easily convey information contained in an Objective-C enum (statuses, etc) to themselves or to the user.
For example:
extension AGSDrawStatus: CustomStringConvertible {
public var description: String {
switch self {
case AGSDrawStatusInProgress:
return "In Progress"
case AGSDrawStatusCompleted:
return "Completed"
default:
return ""
}
}
}
extension AGSDrawStatus: CustomDebugStringConvertible {
public var debugDescription: String {
return "[Draw Status] \(self)"
}
}
let drawStatus:AGSDrawStatus = AGSDrawStatusInProgress
print(drawStatus)
// In Progress
print(drawStatus.description)
// In Progress
print(drawStatus.debugDescription)
// [Draw Status] In Progress
and
(lldb) po drawStatus
▿ [Draw Status] In Progress
- rawValue : 0