我有一个这样的课
class FoundItem : NSObject {
var id : String!
var itemName : String!
var itemId : Int!
var foundBy : String!
var timeFound : String!
init(id: String,
itemName: String,
itemId: Int,
foundBy: String,
timeFound: String)
{
self.id = id
self.itemName = itemName
self.itemId = itemId
self.foundBy = foundBy
self.timeFound = timeFound
}
Run Code Online (Sandbox Code Playgroud)
我把它引用到我的身上
class MapViewVC: UIViewController, MKMapViewDelegate {
var found = [FoundItem]()
var filterItemName : String()
}
Run Code Online (Sandbox Code Playgroud)
我FoundItem是从我的类中FoundItem的一个字典数组生成的firebase查询.然后我得到一个itemName从另一个视图控制器生成的字符串,该控制器是didSelection函数的集合视图.我想获取该字符串,然后使用与我之前itemName的itemName …
您好,我有一个包含多个值的数组,我想尝试过滤掉搜索栏的索引。英语术语的一个例子就像。给我名称“Name2”的索引,并通过检查每个索引的第一个值中的所有字符串来执行此操作。
代码:
// Multiple Errors
var receivedList = [["Name1","Apple","Fresh"],["Name2","Orange","Rotten"],["Name3","Pear","Fresh"],["Name4","Grape","Rotten"]]
filteredData = data.filter({$0 == searchBar.text})
filteredData = receivedList.filter({$0 receivedList[1] == searchBar.Text})
//Im not really sure how to use this or if it's even useful
let searchPredicate = NSPredicate(format: "Orange CONTAINS[C] %@", searchText)
let array = (receivedList as NSArray).filtered(using: searchPredicate)
Run Code Online (Sandbox Code Playgroud)
我在这里检查了这些页面。
还有其他一些人,运气不好