-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的價值,如果有人有想法得益於使用它在我的搜索欄功能
你的變量是「可選的」? – Grimxn
我嘗試過這種方法,但它看起來像var myVarIwantToUse仍然是空的(抱歉我的英語) – matheo972