You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
extensionAGSDrawStatus:CustomStringConvertible{publicvardescription:String{
switch self{case AGSDrawStatusInProgress:return"In Progress"case AGSDrawStatusCompleted:return"Completed"default:return""}}}extensionAGSDrawStatus:CustomDebugStringConvertible{publicvardebugDescription:String{return"[Draw Status] \(self)"}}letdrawStatus: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
The text was updated successfully, but these errors were encountered:
A heads up @philium, the above construct was based on a simplified proof of concept I had built, they aren't reflective of the actual SDK. I built this proof of concept because I won't be posting proprietary code in a public channel and thus the construct above does not reflect the actual codebase but instead a demo.
As for the stringified enum case, I would personally advocate for a proper description as opposed to printing the case name, it's something that can both be used in debugging as well as something that can be used in some sort of UI element.
I would like to introduce a swift toolkit enhancement that would adhere AGS enums to the swift
CustomStringConvertible
andCustomDebugStringConvertible
protocols.This enhancement will allow someone to either:
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:
and
The text was updated successfully, but these errors were encountered: