filter an array in Swift

PHOTO EMBED

Thu Jan 13 2022 10:58:19 GMT+0000 (Coordinated Universal Time)

Saved by @hasnat #swift #filter #array #ios

To Filter Model Array:

var filteredItems = unfilteredItems.filter { $0.cat == "garden" }

Arrange :

self.chatModelArray = self.chatModelArray.sorted { $0.time == $1.time }

To Filter name : 

var filteredItems = unfilteredItems.filter { $0.name.localizedCaseInsensitiveContains(textField.text ?? "") }

To Filter an Array:

let result = arr.filter {$0.contains("ali")}
content_copyCOPY

https://stackoverflow.com/questions/48467867/adding-a-filter-to-an-array-in-swift-4