gpt4 book ai didi

ios - 线程 1 : signal SIGABRT in swift

转载 作者:行者123 更新时间:2023-11-29 05:30:33 25 4
gpt4 key购买 nike

我正在制作 iOS Todo 应用程序,但 AppDelegate.swift 中的标题出现错误

我尝试删除 Main.storyboard 中的 DetailViewController但发生了同样的错误

MemoListVC.swift

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

let row = self.appDelegate.memolist[indexPath.row]

guard let vc = self.storyboard?.instantiateViewController(withIdentifier: "MemoRead") as? MemoReadVC else {
return
}

MemoDetailVC.swift

import UIKit

class MemoDetailVC: UITableViewController {

var param: MemoData?

@IBOutlet var subject: UILabel!
@IBOutlet var contents: UILabel!
@IBOutlet var img: UIImageView!

override func viewDidLoad() {
super.viewDidLoad()

// 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

self.subject.text = param?.title
self.contents.text = param?.contents
self.img.image = param?.image

let formatter = DateFormatter()
formatter.dateFormat = "dd일 HH:mm"
let dateString = formatter.string(from: (param?.date)!)

self.navigationItem.title = dateString
}

}

AppDelegate.swift

import UIKit
import CoreData

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?
var memolist = [MemoData]()

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

错误

2019-08-25 02:30:08.049965+0900 MyMemory[39157:1944071] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] instantiated view controller with identifier "MemoDetail" from storyboard "Main", but didn't get a 

最佳答案

在 MemoListVC.swift 中,我注意到您使用标识符“MemoRead”实例化了 View Controller 。该标识符是否与您在 Storyboard中为要实例化的 View Controller 设置的标识符相同?如果不是,这可能就是导致您的代码失败的原因。

如果不相同,则转到 Storyboard,选择 View Controller ,然后转到右侧检查器侧边栏上的身份检查器(Xcode 10 中左侧第三个图标),然后更改名称您在 MemoListVC.swift 中用于实例化的标识符,为“ Storyboard ID”下的 Storyboard身份检查器中列出的标识符。

关于ios - 线程 1 : signal SIGABRT in swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57640262/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com