我试图在 didFinishLaunchingWithOptions 方法中返回 false,我的应用程序运行成功,没有任何反应,谁能告诉为什么这件事起作用,以及这里有什么区别(真/假)。
我想检查如何在使用 DiffableDataSource 时设置 tableview 单元格的高度。这是代码:
func configureDataSource() {
dataSource = MenuItemDataSource(tableView: MenuItemTablevVew, cellProvider: { (tableView, indexPath, menuItem) -> UITableViewCell? in
guard let cell = tableView.dequeueReusableCell(withIdentifier: self.cellIdentifier) as? MenuItemTableCell else { fatalError("Cell not exists")
}
cell.data = menuItem
return cell
})
}
func createSnapshot(menuItems: [MenuItemModel]) {
var snapshot = MenuItemSnapshot()
snapshot.appendSections([.First])
snapshot.appendItems(menuItems)
dataSource.apply(snapshot, animatingDifferences: false)
}
Run Code Online (Sandbox Code Playgroud) 2022-12-17 11:55:39.440659+0530 StocksApp[83268:1200077] [SceneConfiguration] Info.plist 不包含 UIScene 配置字典(查找名为“(无名称)”的配置)
class ViewController: UIViewController {
override func viewDidLoad() {
// Do any additional setup after loading the view.
DispatchQueue.main.sync { //this line crashes with Thread 1 : EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
print("Rohit Kumar")
}
}
}
Run Code Online (Sandbox Code Playgroud)
在 viewDidLoad 中使用同步方法崩溃,但它适用于异步,我不知道这背后的原因,任何人都可以帮助我。
我知道同步和异步之间的区别。