Is that a possible way to do in conditional statements
if let offer = self.offer_visitor_["Offer"], let video = self.offer_visitor_["VideoReward"], let bday = self.offer_visitor_["BirthdayReward"],let Promotional = self.offer_visitor_["promotional"]{
if !offer.isEmpty && !video.isEmpty && !bday.isEmpty && !Promotional.isEmpty{
return 4
}else if !offer.isEmpty && !bday.isEmpty && !video.isEmpty {
return 3
}else if !offer.isEmpty && !video.isEmpty && !Promotional.isEmpty {
return 3
}else if !offer.isEmpty && !bday.isEmpty && !Promotional.isEmpty {
return 3
}else if !video.isEmpty && !bday.isEmpty && !Promotional.isEmpty {
return 3
}else if !offer.isEmpty && !video.isEmpty {
return 2
}else if !offer.isEmpty && !bday.isEmpty {
return 2
}else if !offer.isEmpty && !Promotional.isEmpty{
return 2
}else if !video.isEmpty && !bday.isEmpty {
return 2
}else if !video.isEmpty && !Promotional.isEmpty {
return 2
}else if !bday.isEmpty && !Promotional.isEmpty {
return 2
}else if !offer.isEmpty {
return 1
}else if !video.isEmpty {
return 1
}else if !bday.isEmpty {
return 1
}else if !Promotional.isEmpty {
return 1
}else{
UIView.transition(with: self.noHistory_Label!,
duration: 0.35,
options: .transitionCrossDissolve,
animations: { [weak self] in
self?.noHistory_Label?.text = UserDefaults.language == "ar" ? ArabicLanguageFile.NoOffers : EnglishLanguageFile.NoOffers
}, completion: nil)
return 0
}
}else{
UIView.transition(with: self.noHistory_Label!,
duration: 1,
options: .transitionCrossDissolve,
animations: { [weak self] in
self?.noHistory_Label?.text = UserDefaults.language == "ar" ? ArabicLanguageFile.NoOffers : EnglishLanguageFile.NoOffers
}, completion: nil)
return 0
}
if dynamic values is that way to use something like that
let count = [arrayData1["Available Offers"]?.count != 0, arrayData1["Redeemtion Offers"]?.count != 0, arrayData1["Redeemtion Vouchers"]?.count != 0, self.arrayData1["Available Vouchers"]?.count != 0].filter { $0 == true }.count
map filter
Thanks
Aucun commentaire:
Enregistrer un commentaire