-1
Я хотел бы использовать значение из функции в другом одномПолучить значение из другой функции быстрой
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> ObsequeCell
{
var cell : ObsequeCell! = tableView.dequeueReusableCellWithIdentifier("cell") as ObsequeCell
if(cell == nil) {
cell = NSBundle.mainBundle().loadNibNamed("cell", owner: self, options: nil)[0] as ObsequeCell;
}
/// CODE ////
var containerTitle = posts.objectAtIndex(indexPath.row).valueForKey("title") as NSString as String
cell.title.text = posts.objectAtIndex(indexPath.row).valueForKey("title") as NSString as String
cell.descriptionOb.text = htmlLessString
println(htmlLessString)
return cell as ObsequeCell
}
func searchBar(searchBar: UISearchBar, textDidChange searchText: String) {
filtered = containerTitle.filter({ (text) -> Bool in
let tmp: NSString = text
let range = tmp.rangeOfString(searchText, options: NSStringCompareOptions.CaseInsensitiveSearch)
return range.location != NSNotFound
})
if(filtered.count == 0){
searchActive = false;
} else {
searchActive = true;
}
self.tableView.reloadData()
}
Так что мне нужно значение containerTitle, чтобы использовать его в моей функции SearchBar, если кто-то есть идея спасибо
Как ваша переменная «необязательна»? – Grimxn
Я пробовал с этим методом, но он выглядит как var myVarIwantToUse, все еще пустой (извините за мой английский) – matheo972