gpt4 book ai didi

swift - 当核心数据中没有找到相关实体时,无法识别的选择器发送到实例

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

我有一个核心数据问题 - 我有两个实体,第二个实体与第一个实体是一对多关系。当尝试在第一个 View Controller 上加载第一个 View Controller 的详细信息和第二个详细信息的 UITableView 时,我希望此 tableView 代码允许我在找到记录时显示一个空白表。相反,我遇到了如上所述的崩溃。我试图将“Event”(相关的 NSSet)覆盖到一个数组中,但我不知道如何调试这个错误。感谢您的指点!

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "eventCell", for: indexPath)

let eventsOnArray = selectedRecipient?.events.allObjects

let event = eventsOnArray![indexPath.row] as! Event
if selectedRecipient?.events.count != nil {
cell.textLabel?.text = event.event

}
return cell
}

添加详细的堆栈跟踪 -

    2018-03-03 10:27:29.419115-0500 Card Tracker[5162:453078] -[Recipient events]: unrecognized selector sent to instance 0x60000009cbb0
2018-03-03 10:27:29.427781-0500 Card Tracker[5162:453078] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Recipient events]: unrecognized selector sent to instance 0x60000009cbb0'
*** First throw call stack:
(
0 CoreFoundation 0x0000000107fd212b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x0000000103d79f41 objc_exception_throw + 48
2 CoreFoundation 0x0000000108053024 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x0000000107f54f78 ___forwarding___ + 1432
4 CoreFoundation 0x0000000107f54958 _CF_forwarding_prep_0 + 120
5 Card Tracker 0x0000000103434fca _T012Card_Tracker010ViewEventsC10ControllerC05tableC0SiSo07UITableC0C_Si21numberOfRowsInSectiontF + 410
6 Card Tracker 0x00000001034352e4 _T012Card_Tracker010ViewEventsC10ControllerC05tableC0SiSo07UITableC0C_Si21numberOfRowsInSectiontFTo + 68
7 UIKit 0x0000000104cd1b4c -[UITableView _numberOfRowsInSection:] + 62
8 UIKit 0x0000000104f840e1 -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 2389
9 UIKit 0x0000000104f8a5ab -[UITableViewRowData rectForFooterInSection:heightCanBeGuessed:] + 487
10 UIKit 0x0000000104f8a711 -[UITableViewRowData heightForTable] + 61
11 UIKit 0x0000000104c7fa65 -[UITableView _updateContentSize] + 372
12 UIKit 0x0000000104cb067d -[UITableView _rebuildGeometry] + 66
13 UIKit 0x0000000104cae03c -[UITableView didMoveToWindow] + 145
14 UIKit 0x0000000104c2b147 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1748
15 UIKit 0x0000000104c44a81 -[UIScrollView _didMoveFromWindow:toWindow:] + 84
16 UIKit 0x0000000104c2ad84 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 785
17 UIKit 0x0000000104c1d1e1 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 151
18 UIKit 0x0000000104c1d0c8 -[UIView(Hierarchy) _postMovedFromSuperview:] + 828
19 UIKit 0x0000000104c2dcbd -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1973
20 UIKit 0x0000000104b504e7 -[_UIParallaxDimmingView didMoveToWindow] + 179
21 UIKit 0x0000000104c2b147 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1748
22 UIKit 0x0000000104c2ad84 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 785
23 UIKit 0x0000000104c1d1e1 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 151
24 UIKit 0x0000000104c1d0c8 -[UIView(Hierarchy) _postMovedFromSuperview:] + 828
25 UIKit 0x0000000104c2dcbd -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1973
26 UIKit 0x0000000104b4b259 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke_2 + 2305
27 UIKit 0x0000000104c25c60 +[UIView(Animation) performWithoutAnimation:] + 90
28 UIKit 0x0000000104b4a903 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke + 260
29 UIKit 0x0000000104c2c271 +[UIView(Internal) _performBlockDelayingTriggeringResponderEvents:] + 188
30 UIKit 0x0000000104b4a21b -[_UINavigationParallaxTransition animateTransition:] + 1270
31 UIKit 0x0000000104d3e3ee -[UINavigationController _startCustomTransition:] + 3678
32 UIKit 0x0000000104d543b4 -[UINavigationController _startDeferredTransitionIfNeeded:] + 686
33 UIKit 0x0000000104d556d3 -[UINavigationController __viewWillLayoutSubviews] + 150
34 UIKit 0x0000000104fb04e2 -[UILayoutContainerView layoutSubviews] + 231
35 UIKit 0x0000000121187008 -[UILayoutContainerViewAccessibility layoutSubviews] + 42
36 UIKit 0x0000000104c34a6d -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1439
37 QuartzCore 0x000000010b5d361c -[CALayer layoutSublayers] + 159
38 QuartzCore 0x000000010b5d77ad _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 401
39 QuartzCore 0x000000010b55e86c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 364
40 QuartzCore 0x000000010b58b946 _ZN2CA11Transaction6commitEv + 500
41 UIKit 0x0000000104b8d167 _afterCACommitHandler + 272
42 CoreFoundation 0x0000000107f74c07 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
43 CoreFoundation 0x0000000107f74b5e __CFRunLoopDoObservers + 430
44 CoreFoundation 0x0000000107f59124 __CFRunLoopRun + 1572
45 CoreFoundation 0x0000000107f58889 CFRunLoopRunSpecific + 409
46 GraphicsServices 0x000000010a77b9c6 GSEventRunModal + 62
47 UIKit 0x0000000104b635d6 UIApplicationMain + 159
48 Card Tracker 0x0000000103417ea7 main + 55
49 libdyld.dylib 0x0000000109170d81 start + 1
50 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

enter image description here

最佳答案

发现两个问题。数据模型中的次要实体称为卡而不是事件。上面@vadian 指出的两个应该在 viewDidLoad 中进行加载。谢谢

关于swift - 当核心数据中没有找到相关实体时,无法识别的选择器发送到实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49061018/

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