有人可以帮我解密这个xcode崩溃日志吗?

时间:2016-10-07 19:26:35

标签: ios uipickerview swift3

我正在使用Swift 3在Xcode 8中开发应用程序,但我对iOS开发一般都很陌生。过去几天我在应用程序上取得了很好的进展,但今天模拟器在成功构建后仍然崩溃。它打印出某种崩溃日志,但我不知道它试图告诉我什么。它突出显示了AppDelegate中的第一个方法,并给出了SIGABRT错误。我最近的更改是我尝试从uitableviewcell按下导航到新视图,并将数据从第一个视图传递到下一个视图。我将发布我认为相关的方法以及崩溃报告。我已经尝试查找SIGABRT错误,但它似乎是一个非特定的错误,阅读错误报告的唯一指南来自iOS 5上的2011年。任何帮助都非常感谢。

崩溃报告:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[mondayOct3_xmlParse.ViewController numberOfComponentsInPickerView:]: unrecognized selector sent to instance 0x7fadd2030000'
*** First throw call stack:
(
0   CoreFoundation                      0x000000010633234b __exceptionPreprocess + 171
1   libobjc.A.dylib                     0x0000000105d9321e objc_exception_throw + 48
2   CoreFoundation                      0x00000001063a1f34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3   CoreFoundation                      0x00000001062b7c15 ___forwarding___ + 1013
4   CoreFoundation                      0x00000001062b7798 _CF_forwarding_prep_0 + 120
5   UIKit                               0x000000010673512f -[UIPickerView _delegateNumberOfComponents] + 56
6   UIKit                               0x000000010673425b -[UIPickerView _updateSelectedRows] + 91
7   UIKit                               0x000000010673432a -[UIPickerView didMoveToWindow] + 102
8   UIKit                               0x0000000106813ae5 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1799
9   UIKit                               0x0000000106813711 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 819
10  UIKit                               0x0000000106813711 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 819
11  UIKit                               0x0000000106806aa8 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 151
12  UIKit                               0x0000000106806996 -[UIView(Hierarchy) _postMovedFromSuperview:] + 857
13  UIKit                               0x00000001068166df -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1982
14  UIKit                               0x0000000106804b95 -[UIView(Hierarchy) addSubview:] + 838
15  UIKit                               0x0000000106c212bf -[UINavigationTransitionView transition:fromView:toView:] + 645
16  UIKit                               0x0000000106938b1b -[UINavigationController _startTransition:fromViewController:toViewController:] + 3314
17  UIKit                               0x00000001069390b9 -[UINavigationController _startDeferredTransitionIfNeeded:] + 874
18  UIKit                               0x000000010693a19b -[UINavigationController __viewWillLayoutSubviews] + 58
19  UIKit                               0x0000000106b311b7 -[UILayoutContainerView layoutSubviews] + 223
20  UIKit                               0x000000010681a344 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
21  QuartzCore                          0x000000010b7dbcdc -[CALayer layoutSublayers] + 146
22  QuartzCore                          0x000000010b7cf7a0 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
23  QuartzCore                          0x000000010b7cf61e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
24  QuartzCore                          0x000000010b75d62c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
25  QuartzCore                          0x000000010b78a713 _ZN2CA11Transaction6commitEv + 475
26  QuartzCore                          0x000000010b78b083 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 113
27  CoreFoundation                      0x00000001062d6e17 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
28  CoreFoundation                      0x00000001062d6d87 __CFRunLoopDoObservers + 391
29  CoreFoundation                      0x00000001062bb4b6 CFRunLoopRunSpecific + 454
30  UIKit                               0x000000010674fdb6 -[UIApplication _run] + 434
31  UIKit                               0x0000000106755f34 UIApplicationMain + 159
32  mondayOct3_xmlParse                 0x000000010579067f main + 111
33  libdyld.dylib                       0x000000010995c68d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

UITableView功能

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    self.performSegue(withIdentifier: "detailViewSegue", sender: indexPath);
}

func perpareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    let destination = segue.destination as? viewTwoViewController
    let index = (sender as! NSIndexPath).row;

    destination?.newsStory = newsStories[index]
    destination?.storyExpires = storiesExpire[index]
    destination?.storySeverity = storiesSeverity[index]
    destination?.storySummary = storiesSummary[index]
    destination?.storyEffective = storiesEffective[index]
    destination?.storyUrgency = storiesUrgency[index]
    destination?.storyCertainty = storiesCertainty[index]
    //        if (polygon.count != 0){
    //            destination?.polygon = polygon[index]
    //        }
}

接收视图 class viewTwoViewController:UIViewController {

@IBOutlet weak var titleOutlet: UILabel!
@IBOutlet weak var expiresOutlet: UILabel!
@IBOutlet weak var severityOutlet: UILabel!
@IBOutlet weak var effectiveOutlet: UILabel!
@IBOutlet weak var urgencyOutlet: UILabel!
@IBOutlet weak var certaintyOutlet: UILabel!
@IBOutlet weak var summaryOutlet: UILabel!

var newsStory = ""
var storyExpires = ""
var storySeverity = ""
var storySummary = ""
var storyEffective = ""
var storyUrgency = ""
var storyCertainty = ""

override func viewDidLoad() {
    super.viewDidLoad()

    titleOutlet.text = newsStory
    expiresOutlet.text = storyExpires
    severityOutlet.text = storySeverity
    effectiveOutlet.text = storyEffective
    urgencyOutlet.text = storyUrgency
    certaintyOutlet.text = storyCertainty
    summaryOutlet.text = storySummary

    // Do any additional setup after loading the view.
}

以下是错误引用的pickerview函数:

private func numberOfComponentsInPickerView(_ pickerView: UIPickerView) -> Int
{
    return 1
}

func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int
{
    return state.count
}

func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String!
{
    return state[row]
}

func pickerView(_ pickerView: UIPickerView, didSelectRow row:Int, inComponent component:Int)
{
    stateAbbrev = state[row]
    url = NSURL(string: "http://alerts.weather.gov/cap/"+stateAbbrev+".php?x=0")
    parseXML()
    tableViewOutlet.reloadData()
}

1 个答案:

答案 0 :(得分:0)

Swift 3中组件数量的签名功能不同。应该是:

func numberOfComponents(in pickerView: UIPickerView) -> Int {
    ...
}