Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Mention what are the collection types available in Swift?



Mention what are the collection types available in Swift?..

Answer / iosraj

In Swift, collection types come in two varieties Array and Dictionary

Array: You can create an Array of a single type or an array with multiple types. Swift usually prefers the former one

Example for single type array is,

Var cardName : [String] = [ “Robert” , “Lisa” , “Kevin”]

// Swift can infer [String] so we can also write it as:

Var cardNames = [ “Robert”, “Lisa”, “Kevin”] // inferred as [String]

To add an array you need to use the subscript println(CardNames[0])

Dictionary: It is similar to a Hash table as in other programming language. A dictionary enables you to store key-value pairs and access the value by providing the key

var cards = [ “Robert”: 22, “Lisa” : 24, and “Kevin”: 26]

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Apple iOS Swift Interview Questions

How can you add table view?

0 Answers  


What lazy stored properties is and when it is useful?

0 Answers  


Explain what Lazy stored properties is and when it is useful?

1 Answers  


Is it worth learning swift 2019?

0 Answers  


What is enum in swift?

0 Answers  


What is the purpose of swift?

0 Answers  


How would you define variables and constants in swift programming language?

0 Answers  


What is reuseidentifier in swift?

0 Answers  


Mention what is the characteristics of Switch in Swift?

1 Answers  


What are methods in swift?

0 Answers  


Does swift support multiple inheritance?

0 Answers  


Is swift an object-oriented programming language?

0 Answers  


Categories