SWIFT 写了一个项目,感觉跟objective-c 相比确实流畅很多。
override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. let refreshControl = UIRefreshControl() refreshControl.attributedTitle = NSAttributedString(string: "下拉刷新") refreshControl.addTarget(self, action: "loadDataSource", forControlEvents: UIControlEvents.ValueChanged) self.refreshControl = refreshControl } override func viewDidAppear(animated: Bool) { super.viewDidAppear(animated) loadDataSource(); }
跟原来的OBJ-C 代码其实差不多,只不过加了写起来快罢了。
项目地址:
https://github.com/xhzengAIB/XHNewsParsingSwift