Swift 3.0 - Check if array contains element with property
if array.contains(where: { $0.someProperty == "matchProperty" }) {// Property found
} else {
// Property not found
}
let elements = [1, 2, 3, 4, 5]
if elements.contains(5) {
// Found
} else {
// Not Found
}
No comments:
Post a Comment