我想在这个方法中重新加载一个块中的表数据:
原文链接:https://www.f2er.com/swift/320359.htmlimport UIKit import AssetsLibrary class AlbumsTableViewController: UITableViewController { var albums:ALAssetsGroup[] = [] func loadAlbums(){ let library = IAAssetsLibraryDefaultInstance library.enumerateGroupsWithTypes(ALAssetsGroupType(ALAssetsGroupAll),usingBlock: {(group,stop) in if group { self.albums.append(group) } else { dispatch_async(dispatch_get_main_queue(),{ self.tableView.reloadData() }) } },failureBlock: { (error:NSError!) in println("Problem loading albums: \(error)") }) } override func viewDidLoad() { super.viewDidLoad() loadAlbums() // Uncomment the following line to preserve selection between presentations // self.cleaRSSelectionOnViewWillAppear = false // Uncomment the following line to display an Edit button in the navigation bar for this view controller. //self.navigationItem.rightBarButtonItem = self.editButtonItem }
但是else块不会执行。我得到的错误是:
'performSelectorOnMainThread' is unavailable: 'performSelector' methods are unavailable
那么swift中“performSelectorOnMainThread”的替代方法是什么?
更新:
我现在得到一个中止错误。这是控制台的样子:http://cl.ly/image/3D0h1x433P0R