UPDATE:
If you are using a button to add/remove values from the list of fruits and you are utilizing a set. When you click the add button, first check if the fruit is already in the set, if it is, then don't add it.
When you click the remove button, remove it from the set.
You can iterate through the array storing unique values in a Set.
For each value in the array, check if the Set does not contain the current item. If it doesn't, then add it to the Set and to an output array. Repeat for each item to get an array of unique values.
i.e.
func unique<S : Sequence, T : Hashable>(inputArray: S) -> [T] where S.Iterator.Element == T {
var output = [T]()
var uniqueValues = Set<T>()
for fruit in inputArray {
if !uniqueValues.contains(fruit) {
output.append(fruit)
uniqueValues.insert(fruit)
}
}
return output
}
let vals = ["orange", "grape", "strawberry", "strawberry", "apple", "orange", "raspberry"]
let uniqueVals = unique(vals) // ["orange", "grape", "strawberry", "apple", "raspberry"]