Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between @available and #available in swift 2.0

Tags:

swift

Swift 2.0 allows availability checking by using @available or #available, but what is the difference between using @available and #available?

like image 348
Ankit Goel Avatar asked Sep 24 '15 12:09

Ankit Goel


People also ask

What is the difference between current balance and available balance Navy Federal?

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.

What's the difference between available and balance?

'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.

Whats the difference between current balance and available credit?

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.

What's the difference between total balance and available balance?

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.


1 Answers

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

like image 67
AaoIi Avatar answered Oct 03 '22 10:10

AaoIi