I would like to detect on Swift that the UITableView has been loaded.
http://qiita.com/corocorococoro/items/1c80681cd7e1fddc3ba3
See the for information on
extension UITableView {
・・・
}
I tried to write it in , but the above reference URL is
-(void) reloadDataAndWait:(void(^)(void))waitBlock{
self reloadData;
if(waitBlock){
waitBlock();
}
}
I don't know how to write in Swift.
swift objective-c
If you transplant it directly to Swift, it will be as follows.
extension UITableView {
func reloadDataAndWait(waitBlock:(()->())?){
reloadData()
if let waitBlock = waitBlock {
waitBlock()
}
}
}
The usage is as follows:
tableView.reloadDataAndWait{
NSLog("numberofsection%d", self.tableView.numberOfSections)
}
As you can see in the comments in StackOverflow's answer further down the link, this code is now available in
tableView.reloadData()
NSLog("numberofsection%d", self.tableView.numberOfSections)
and reloadData()
followed by processing.
So there's no point in creating such a method.
© 2024 OneMinuteCode. All rights reserved.