核心代码如下
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
}
怎么接收 workTime () -> CGFloat 这个方法的返回值
看到perform 的返回值是 Unmanaged<AnyObject>!,不用 perform 的话还有其他相同功能的方法么?
public func perform(_ aSelector: Selector!) -> Unmanaged<AnyObject>!
下面是全部代码
code: https://github.com/CoderYLZha...
http://stackoverflow.com/ques...
黄舟2017-04-18 09:52:09
왜인지는 모르겠지만 항상 당신이 하는 일이 반패턴이라는 느낌이 듭니다.
그러나 여기에는 오래된 아이디어가 있습니다. 결과를 포인터로 저장하는 변수를 전달하는 것입니다.
으아아아다음으로 변경됨:
으아아아