因此,我主要基于此苹果教程Create a Table View构建表视图,但是在运行我的应用程序时遇到了问题。问题是,当我运行应用程序时,我收到了可怕的SIGABRT错误。
注意1:当loadlist()在ViewDidLoad中时,我只会收到SIGABRT错误
所以我添加了一个豁免断点,并得到了这个错误:
objc [7603]:STGenericIntentDateRange类在/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/SiriTasks.framework/SiriTasks和/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/PhotosUI.framework/PhotosUI。将使用两者之一。哪一个未定义。
objc [7603]:GKStateMachine类在/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/GameCenterFoundation.framework/GameCenterFoundation和/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/GameplayKit.framework/GameplayKit。将使用两者之一。哪一个未定义。
(lldb)
为了记录,我的TableViewController看起来像这样:
import UIKit
class LevelTableViewController: UITableViewController {
var levelsArray = [Level]()
override func viewDidLoad() {
super.viewDidLoad()
//Load the data
loadlist()
}
func loadlist(){
let Level1:Level = Level(name: "Level1")!
levelsArray += [Level1]
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return levelsArray.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cellid = "LevelTableViewCell"
let cell = tableView.dequeueReusableCellWithIdentifier(cellid, forIndexPath: indexPath) as! LevelTableViewCell
// Fetches the appropriate meal for the data source layout.
let Level = levelsArray[indexPath.row]
cell.ListName.text = Level.name
return cell
}
/*
// Override to support conditional editing of the table view.
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
// Return false if you do not want the specified item to be editable.
return true
}
*/
/*
// Override to support editing the table view.
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == .Delete {
// Delete the row from the data source
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
} else if editingStyle == .Insert {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) {
}
*/
/*
// Override to support conditional rearranging of the table view.
override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
// Return NO if you do not want the item to be re-orderable.
return true
}
*/
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
而我的TableViewCell是这样的:
import UIKit
class LevelTableViewCell:UITableViewCell {
//Declaration of properties
@IBOutlet weak var ListName: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
我的类定义是这样的:
import Foundation
import UIKit
class Level {
// MARK: Properties
var name: String
init?(name: String) {
// Initialize stored properties.
self.name = name
if name.isEmpty {
return nil
}
}
}
帮助将不胜感激。
最佳答案
检查这些类是否重复,就像它们在两个框架中一样。如果它们重复但几乎没有什么不同,则您“可能”尝试删除一个版本,然后使用不同的名称再次添加它们。请注意,此选项可能需要进行一些更改,因为可以从代码中的更多点调用这些类。
如果类相同,请尝试使用Finder查找它们,进行复制,然后从项目导航器中将其删除,然后重试。如果出现严重错误,只需将它们再次添加到项目中,别忘了选中“复制项目”
关于ios - 如何修复SIGABRT错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32455559/