I have created a custom class called MenuItem:
import Foundation
class MenuItem {
var title: String
var tag: Int
var image: UIImage
init (title: String, tag: Int, image: UIImage) {
self.title = title
self.tag = tag
self.image = image
}
}
I am adding these objects to an array.
How can I check if an array contains a specific menu item?
This is a simplified version of what I have tried.
let menuOptionInventory = MenuItem(title: "Inventory", tag: 100, image: UIImage(imageLiteral: "871-handtruck"))
var menuOptions = [MenuItem]()
menuOptions.append(menuOptionInventory)
if (menuOptions.contains(menuOptionInventory)) {
//does contain object
}
When I do this I get this error message:
Cannot convert value of type 'MenuItem' to expected argument type '@noescape (MenuItem) throws -> Bool'