小编Art*_*iom的帖子

Xcode - 该属性在此上下文中可能不可用

看来 Xcode 给开发者带来了越来越多的新问题。有谁知道这个问题到底是什么以及如何解决它?:该属性是在 XXX 上定义的,并且在此上下文中可能不可用。

该属性存在于此范围内,并且代码运行没有任何问题,但自动完成功能一如既往地被破坏......在此输入图像描述

xcode autocomplete ios swift

16
推荐指数
1
解决办法
1万
查看次数

Xcode 14.1 - 启动应用程序时模拟器不断冻结

我正在使用Xcode 14.1、MacOS 13.2.1,并运行不同的模拟器(iPhone 14 Pro 16.1等),每重新运行应用程序 2-4 次,模拟器就会冻结。Xcode 显示正在启动...但模拟器显示黑屏。等待没有帮助。所以我经常需要关闭模拟器,这真的很烦人。

有没有办法解决它或者它目前是“正常”行为吗?

xcode simulator ios swift

5
推荐指数
1
解决办法
596
查看次数

删除行后立即重新加载 TableView 数据

在我的中tableView,我删除了一行,之后我需要重新加载整个表以重新计算一些值。最好的方法是什么?由于deleteRows没有完成处理程序,并且根据对 SO 的评论,我永远不应该tableView.reloadData()在删除行后立即调用。

func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
        let deleteAction = UIContextualAction(style: .normal, title: "Delete") { [weak self] (action, view, completion) in
            guard let weakSelf = self else { return }
            
            CoreDataManager.manager.deleteActivity(activity: weakSelf.sortedActivites[indexPath.row])
            weakSelf.sortedActivites.remove(at: indexPath.row)
            tableView.deleteRows(at: [indexPath], with: .automatic)
            tableView.reloadData()
            completion(true)
        }
        
      deleteAction.backgroundColor = UIColor.red
        
      return UISwipeActionsConfiguration(actions: [deleteAction])
}
Run Code Online (Sandbox Code Playgroud)

xcode objective-c uitableview ios swift

1
推荐指数
1
解决办法
704
查看次数

Swift 中具有有限精度小数位的字符串数字

将数字“1234.5678”转换StringNSNumber精度 -> 1234.56 并返回String“1234.56”的最快方法是什么。

let numberFormatter = NumberFormatter()
numberFormatter.maximumFractionDigits = 2
numberFormatter.string(from: numberFormatter.number(from: "1234.534234")!)
Run Code Online (Sandbox Code Playgroud)

这段代码看起来不太漂亮。有任何想法吗?

string precision nsnumberformatter swift

1
推荐指数
1
解决办法
422
查看次数