This week, I published my first CocoaPods library named “Boonary”.
In GitHub, https://github.com/imaizume/boonary/
This makes it easier for conversion between Swift’s Bool and Int.
let thisIs1: Int = true.binary
let thisIsTrue: Bool = 1.boolean
Sometimes you will need to convert 1 to true and 0 to false, especially when you get/post HTTP request with binary parameter like:
parameter["loggedIn"] = isLoggedIn ? 1 : 0
parameter["isPremiumUser"] = isPremium ? 1 : 0
But it may burden for you to write such a code in every necessary part.
It’s even risky because you will make mistake to put 0/1 in reverse or misunderstand the meaning of the flag. …