从Show(push)segue返回时XPC连接中断

时间:2019-12-24 22:21:35

标签: swift xcode xpc

我有一个使用简单列表和详细信息视图的iOS应用。用户可以为谓词选择四(4)个可能的变量,然后根据该选择从Core Data数据库填充表。对于Pa'u,top,dress等三个变量,该应用程序运行良好,用户可以将详细信息视图显示(推入)到列表视图中。但是,使用第四个变量裙子,详细视图显示在列表视图上,但是用户无法返回,并且我得到了消息,XPC连接中断。我正在使用Xcode 11.3和iOS 13.3。

要填充我使用的列表:

     override func viewWillAppear(_ animated: Bool) {
  super.viewWillAppear(animated)

  guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
      return
  }

  let managedContext = appDelegate.persistentContainer.viewContext
  let fetchRequest = NSFetchRequest<NSManagedObject>(entityName: "Costumes")
    let predicateThree = NSPredicate(format: "subType CONTAINS[c] %@", costumeChoice)
    fetchRequest.predicate = predicateThree
    let sortDescriptorOne = NSSortDescriptor(key: "baseColor", ascending: true)
    let sortDescriptorTwo = NSSortDescriptor(key: "plain", ascending: false)
    fetchRequest.sortDescriptors = [sortDescriptorOne, sortDescriptorTwo]

  do {
    costumes = try managedContext.fetch(fetchRequest) as! [Costumes]
  } catch let error as NSError {
    print("Could not fetch. \(error), \(error.userInfo)")
  }

    self.tableView.reloadData()
}

并将数据添加到我使用的详细信息视图中:

         if segue.identifier == "costumeDetailSegue" {

        guard let cell = sender as? UITableViewCell,
            let indexPath = tableView.indexPath(for: cell)
            else {return}

        let selectedCostume = costumes[indexPath.row]

        let detailViewController = segue.destination as! CostumeDetailViewController
        detailViewController.selectedCostume = selectedCostume
        detailViewController.costumeChoice = costumeChoice
    }

详细视图数据已加载:

     override func viewDidLoad() {
    super.viewDidLoad()

    title = costumeChoice

    costumeNameLabel.text = selectedCostume.name
    costumeColorLabel.text = selectedCostume.baseColor
    costumePatternLabel.text = selectedCostume.plain
    costumeQuantityLabel.text = selectedCostume.quantity
    costumeDetailImageView.image = UIImage(data: selectedCostume.iImage! as Data)
    pickedCostumeNotes = selectedCostume.notes
    pickedCostumeBinNo = selectedCostume.binNo

    if pickedCostumeNotes != nil {
        passedCostumeNotes = pickedCostumeNotes
    } else {
        passedCostumeNotes = "No notations"
    }

    if pickedCostumeBinNo != nil {
        passedCostumeLocations = pickedCostumeBinNo
    } else {
        passedCostumeLocations = "No notations"
    }
}

我不明白为什么三个可能的“ costumeChoice”变量有效而第四个变量无效。

0 个答案:

没有答案