Junior — Middle
What types of collections have you worked with in practice?
sobes.tech AI
Answer from AI
In iOS development practice, it is common to work with various collections from the Swift standard library:
- Array — an ordered list of elements that can be accessed by index. Used for storing sequences of data.
- Set — an unordered collection of unique elements, useful for quick search and eliminating duplicates.
- Dictionary — a collection of key-value pairs where keys are unique. Often used for storing data with fast access by key.
Example of using Array:
var fruits: [String] = ["Apple", "Banana", "Cherry"]
fruits.append("Date")
print(fruits[0]) // Apple
Collections are also used in UIKit and SwiftUI for displaying lists, for example, UITableViewDataSource works with data arrays.