gpt4 book ai didi

ios - 连接 socket "Thread 1: signal SIGABRT"和 "datasource "后出现错误 "delegate"

转载 作者:可可西里 更新时间:2023-11-01 02:09:04 28 4
gpt4 key购买 nike

所以我一直在学习在线 Swift 类(class),并且正在创建一个 TableView 。我几乎复制了教程中的所有代码,只做了一些调整(因为类(class)是用旧版本的 swift 教授的,但我使用的是 swift 3)。根据教程,我应该得到一个显示名称的 4 行 TableView ,但我得到的是“signal SIGABRT”错误。并且没有具体指出错误。

这里有什么问题吗?如果我没有连接“数据源”导出,我可以毫无问题地运行模拟器,但我不会得到显示的名称。但是,如果我进行连接,我什至无法运行模拟器。我真的希望我已经把问题说清楚了,而且对读者足够友好!

import UIKit

class ViewController: UIViewController, UITableViewDelegate{

var cellContent = ["xiaohong","xiaohua", "xiaogang" ,"xiaoxiao"]

public override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
public func tableView(_tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return cellContent.count
}
public func tableView(_tableView: UITableView, cellForRowAtindexPath indexPath:NSIndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: UITableViewCellStyle.default,reuseIdentifier:"Cell")
cell.textLabel?.text = cellContent[indexPath.row]
return cell }
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}

为了让它更清楚,我想在这里粘贴整个错误消息!

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


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

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}

非常感谢您!

最佳答案

唯一能想到的问题。是不是你的tableview methods headers和data source method headers不匹配:

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
<#code#>
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
<#code#>
}

cellForRow 方法中的问题。它与 DataSource 方法不匹配。

关于ios - 连接 socket "Thread 1: signal SIGABRT"和 "datasource "后出现错误 "delegate",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41414659/

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