-
-
Save AndrewSB/05517bf4a9ac25c8a7d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assuming you have a class called API for all your API stuff | |
extension API { | |
enum PaidStatus: String { | |
case Paid | |
case Scheduled | |
} | |
} | |
if let paidStatus = API.PaidStatus(rawValue: paystubData.status.capitilzedString) { | |
switch paidStatus { | |
case .Paid: | |
cell.paidStatusLabel.text = API.PaidStatus.Paid.rawValue.uppercaseString | |
case .Scheduled: | |
cell.paidStatusLabel.text = API.PaidStatus.Paid.rawValue.uppercaseString | |
} | |
// (or I'd just recommend not switching and just doing this) | |
cell.paidStatusLabel.text = paidStatus.rawValue.uppercaseString | |
} else { | |
cell.paidStatusLabel.text = "" | |
} | |
// Or a beautiful one liner would be | |
cell.paidStatusLabel.text = API.PaidStatus(rawValue: paystubData.status.capitilzedString)?.rawValue.uppercaseString ?? "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment