Number Formatting in SWIFT

Member

sadie.beer

by sadie.beer , in category: Swift , 2 months ago

Number Formatting in SWIFT 😁

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
func onlyCashLessEUR(_ rates : [CurrencyRateMto]) ->  CurrencyRateItem {
    var EUR : CurrencyRateItem? = nil
    let cashLessEUR = rates.filter({$0.type.enumValue == CurrencyRateTypeMtoEnum.CASHLESS && $0.currency.isEUR() == true})
    if(cashLessEUR.count > 0){
        EUR = CurrencyRateItem(
            cashLessEUR.first?.currency.getIcon(),
            (cashLessEUR.first?.currency.id)!,
            NumberFormatting.sum(cashLessEUR.first?.buyPrice?.price),
            NumberFormatting.sum(cashLessEUR.first?.sellPrice?.price))
    }
    if(EUR == nil){
        EUR = CurrencyRateItem(
            UIImage.init(named: "currency_eur"),
            "EUR",
            "-",
            "-")
    }
    return EUR!
}


Facebook Twitter LinkedIn Telegram Whatsapp Pocket

no answers