我想获取我的自定义相册的所有照片。但我得到的是以下错误。
我的代码
let collections:PHFetchResult = PHAssetCollection.fetchAssetCollections(with: .album, subtype: .any, options: fetchOptions)
Run Code Online (Sandbox Code Playgroud)
我得到的错误
“守护进程返回的错误:错误域=com.apple.accounts 代码=7“(空)”
有想法该怎么解决这个吗?
我目前正在开发一个应用程序,它以下列格式返回json
"location_subtype"="somevalue"; "location_type"=强制; month ="2015-01"; "outcome_status"= {category ="somevalue"; date ="somevalue"; };
如果"outcome_status"具有值,则显示类别和日期,但是如果"outcome_value"没有任何值(在大多数情况下),则显示如下
"location_subtype"="somevalue"; "location_type"=强制; month ="2015-01"; "outcome_status"=""; "persistent_id"="";
问题是我如何检查outcome_status的值是否不是"null"?
我已经尝试了以下方法将类别和日期存储到标签中,但它会遇到错误,第一个if语句应该检查该值是否为null,如果它不是转到下一个if语句.然而,它继续下一个if语句,我得到以下错误
线程1:EXC_BAD_ACCESS(代码= 2,地址= 0x102089600)
if (dict["outcome_status"] != nil)
{
if ((dict["outcome_status"]as NSDictionary)["category"] != nil)
{
outcomeStatusLabel.text = ((dict["outcome_status"]as NSDictionary)["category"] as NSString)
outcomeStatusLabel.font = UIFont.systemFontOfSize(14.0);
outcomeStatusLabel.numberOfLines = 0
}
if ((dict["outcome_status"]as NSDictionary)["date"] != nil)
{
outcomeDateLabel.text = ((dict["outcome_status"]as NSDictionary)["date"] as NSString)
outcomeDateLabel.font = UIFont.systemFontOfSize(14.0);
outcomeDateLabel.numberOfLines = 0
}
}
Run Code Online (Sandbox Code Playgroud)
如果我删除第一个if语句,它只会在"outcome_status"="null"时崩溃,并且如果"outcome_status"中有一些值则完全正常
我需要做什么,如果值为null,它会在1st if语句处停止?
先感谢您.
我正在创建一个新应用程序,我想放入一个隐藏文件夹中。可通过 Face ID/Touch ID 访问。我已经实现了代码,但是当我运行该应用程序并使用 Face ID 时。该应用程序因错误“NSInternalInconsistencyException”而崩溃
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread.
Run Code Online (Sandbox Code Playgroud)
在我的 Viewcontroller 中,我将视图设置为:
override func viewDidLoad() {
super.viewDidLoad()
let cornerRadius : CGFloat = 10.0
containerView.layer.cornerRadius = cornerRadius
tableView.clipsToBounds = true
tableView.layer.cornerRadius = 10.0
// 1
let context = LAContext()
var error: NSError?
// 2
// check if Touch ID is available
if …Run Code Online (Sandbox Code Playgroud) 有没有办法定位清除按钮?我想将其向下移动一点,以便与文本输入处于同一级别。有任何想法吗?
我的文本字段已经是另一个处理效果的类的子类。包括“clearButtonRect”功能不起作用。
@IBDesignable open class HoshiTextField: TextFieldEffects {
//effect functions..
override open func clearButtonRect(forBounds bounds: CGRect) -> CGRect {
return CGRect(x: 0, y: 0.2, width: 0.1, height: 0.3)
}
}`
Run Code Online (Sandbox Code Playgroud)

我目前不确定如何解决这个问题.基本上我有一个tableview,我可以通过滑动删除数据.以下是受影响线的代码.
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
// Delete the row from the data source
guard let id = CastService.instance.datsSource[indexPath.row].id else {return}
CastService.instance.deleteCast(id: id, completion: { (success) in
if success {
// Have the below line and that crashes. I believe this is because database has already removed the data
tableView.deleteRows(at: [indexPath], with: .fade)
// Added below line to see if reloading data does anything, however nothing happened, data …Run Code Online (Sandbox Code Playgroud)