У меня небольшие проблемы с моим проектом. Я продолжаю получать две ошибки для «Использование необъявленного типа« Наркотик ».Использование незаявленного типа «Наркотик»
У меня был поиск в Интернете, но я не могу решить эту проблему.
Вот код, вызывающий проблему. Линии, ответственные это
пусть снадобья: Drug
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("SearchCell", forIndexPath: indexPath)
let Drug : Drug
if searchController.active && searchController.searchBar.text != "" {
Drug = filtereddrugs[indexPath.row]
} else {
Drug = drugs[indexPath.row]
}
cell.textLabel!.text = Drug.name
cell.detailTextLabel!.text = Drug.category
return cell
}
func filterContentForSearchText(searchText: String, scope: String = "All") {
filtereddrugs = drugs.filter({(Drug : Drug) -> Bool in
let categoryMatch = (scope == "All") || (Drug.category == scope)
return categoryMatch && Drug.name.lowercaseString.containsString(searchText.lowercaseString)
})
tableView.reloadData()
}
// MARK: - Segues
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showDetail" {
if let indexPath = tableView.indexPathForSelectedRow {
let Drug: Drug
if searchController.active && searchController.searchBar.text != "" {
Drug = filtereddrugs[indexPath.row]
} else {
Drug = drugs[indexPath.row]
}
let controller = (segue.destinationViewController as! UINavigationController).topViewController as! DetailViewController
controller.detailDrug = Drug
controller.navigationItem.leftBarButtonItem = splitViewController?.displayModeButtonItem()
controller.navigationItem.leftItemsSupplementBackButton = true
Вопросы, требующие помощи по отладке («** почему этот код не работает? **)) должны включать в себя желаемое поведение, конкретную проблему или ошибку и кратчайший код, необходимый для его воспроизведения ** в самом вопросе ** , Вопросы без ** ясного заявления о проблеме ** не полезны для других читателей. См. [Как создать минимальный, завершенный и проверяемый пример] (http://stackoverflow.com/help/mcve). – Biffen
Добро пожаловать в SO, пользователь обычно не открывает загруженный проект и исправляет его. Дайте некоторый код .. мы не знаем, как выглядит ваш код, .. – Dravidian
Добро пожаловать в [SO], пожалуйста, просмотрите раздел справки о том, что спросить, и как его спросить. ** ** укажите ваш код в вопросе. – ppeterka