ViewController.swift
//Define array
let fruitArray = ["Pineup", "Kiwi", "mango"]
//Get the number of elements in the array here
let length = fruitArray.count
//Display acquisition results
print(length) //result(3)
Now you can get the number of elements. If you can get the number of elements, you can also perform conditional branching with that number, which is convenient.
ViewController.swift
//Define array
let fruitArray = ["Pineup", "Kiwi", "mango"]
//Get the number of elements in the array here
let length = fruitArray.count
//Conditional branch example
if length == 1 {
//Describe the processing in case of 1
} else if length == 2 {
//Describe the processing in case 2
} else if length == 3 {
//In case of 3, describe the process
}