Swift 2.0 allows availability checking by using @available
or #available
, but what is the difference between using @available
and #available
?
What is the difference between available balance and current balance? Your Available Balance is what is actually available for you to spend, your Current Balance is the available balance plus any pending transactions on the account.
'Balance' is the amount of money in your account before all pending transactions have been processed. 'Available' is the amount that you can spend today, and is a more accurate reflection of how much you can spend at that time.
Your current balance is the total of all the posted transactions as of the previous business day. Your available credit is figured by subtracting your current balance (or amount already used) from your credit limit and adding any outstanding charges that have not posted yet.
Your Total Balance is the total amount held in your account. Your Available Balance might be higher or lower than your Total Balance, as it accounts for pending transactions in your bank accounts that have not yet cleared.
You can use if #available
to run version-specific code in small blocks, like the following :
if #available(iOS 9, *) {
// use UIStackView for example
} else {
// do something else
}
But what if whole methods are off limits, Or perhaps even whole classes? Swift 2 has these scenarios covered too, using the @available
attribute.
@available(iOS 9, *)
func useStackView() {
// use UIStackView for example
}
More details : https://www.hackingwithswift.com/new-syntax-swift-2-availability-checking
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With