var tweakEntries = [(title : String, array : [Array<String>])]()
override func viewDidLoad() {
super.viewDidLoad()
tableView.tableFooterView = UIView()
navigationItem.title = "设置"
//tableView.separatorStyle = .none
let timeSettingArr = [
["工作时间间隔","workTime","setWorkTime"],
["休息时间间隔","relaxTime","setRelaxTime"],
]
let _ = [
["通知标题","",""],
["通知语","",""]
]
let _ = [
["显示背景图片","displayStatus","setDisplayStatus"]
]
tweakEntries = [
("时间设置",timeSettingArr),
//("通知设置",localNoti),
//("其他设置",otherSettingArr)
]
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let section = indexPath.section
let row = indexPath.row
let identifier = "SettingCell"
var cell = tableView.dequeueReusableCell(withIdentifier: identifier)
if (cell == nil) {
cell = SettingCell.init(style: .subtitle, reuseIdentifier: identifier)
}
cell?.textLabel?.text = tweakEntries[section].array[row][0]
let methodName = tweakEntries[section].array[row][1];
print("\(methodName)")
let method : Selector = Selector(methodName)
let detailText = perform(method)
//let temp : CGFloat = detailText as! CGFloat
//cell?.detailTextLabel?.text = "\(temp)"
return cell!
}
func workTime() -> CGFloat {
return 11.0
}
如何获得返回值
执行:
public func perform(_ aSelector: Selector!) -> Unmanaged<AnyObject>!
使用元组使代码更容易扩展
tableView delegateMethod和dataSouseMethod根据元组returnValue
必须使用表演吗?是否有其他功能