我有一个包含键和值的模型。我将此值作为函数参数传递到一个 swift 文件中。每当我尝试在调试模式下运行应用程序并且无法崩溃时。但是在 crashlytics 中发生崩溃,我收到的错误为:-
Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x1926611b8 __exceptionPreprocess
1 libobjc.A.dylib 0x19109855c objc_exception_throw
2 CoreFoundation 0x192668268 __methodDescriptionForSelector
3 CoreFoundation 0x192665270 ___forwarding___
4 CoreFoundation 0x19255e80c _CF_forwarding_prep_0
5 libswiftCore.dylib 0x102be192c (Missing)
6 libswiftCore.dylib 0x102ba0c80 _TFSSCfT12_cocoaStringPs9AnyObject__SS
7 libswiftFoundation.dylib 0x1030a6df8 _TZFE10FoundationSS36_unconditionallyBridgeFromObjectiveCfGSqCSo8NSString_SS
8 Myproject 0x100520e9c DetailsAndDescriptionCell.configureDetailSection(model : Any, lastIndex : Bool) -> () (DetailsAndDescriptionCell.swift:34)
9 Myproject 0x1005224b4 @objc DetailsAndDescriptionCell.configureDetailSection(model : Any, lastIndex : Bool) -> ()
10 Myproject 0x10043d19c -[MyController DetailsInCategories:withTableView:AndIndexPath:] (MyController.m:418)
11 Myproject 0x10043cb18 -[MyController tableView:cellForRowAtIndexPath:] (MyController.m:340)
12 UIKit 0x198859b58 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:]
13 UIKit 0x198859d88 -[UITableView _createPreparedCellForGlobalRow:willDisplay:]
14 UIKit 0x198847320 -[UITableView _updateVisibleCellsNow:isRecursive:]
15 UIKit 0x19885edec -[UITableView _performWithCachedTraitCollection:]
16 UIKit 0x1985fade8 -[UITableView layoutSubviews]
17 UIKit 0x198513a80 -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
18 QuartzCore 0x1959c19d8 -[CALayer layoutSublayers]
19 QuartzCore 0x1959b64cc CA::Layer::layout_if_needed(CA::Transaction*)
20 QuartzCore 0x1959b638c CA::Layer::layout_and_display_if_needed(CA::Transaction*)
21 QuartzCore 0x1959333e0 CA::Context::commit_transaction(CA::Transaction*)
22 QuartzCore 0x19595aa68 CA::Transaction::commit()
23 QuartzCore 0x19595b488 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*)
24 CoreFoundation 0x19260e0c0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
25 CoreFoundation 0x19260bcf0 __CFRunLoopDoObservers
26 CoreFoundation 0x19260c180 __CFRunLoopRun
27 CoreFoundation 0x19253a2b8 CFRunLoopRunSpecific
28 GraphicsServices 0x193fee198 GSEventRunModal
29 UIKit 0x1985817fc -[UIApplication _run]
30 UIKit 0x19857c534 UIApplicationMain
31 Myproject 0x10051343c main (AppDelegate.swift:35)
32 libdispatch.dylib 0x19151d5b8 (Missing)
这是我的模型:-
@interface KeywordsModel : NSObject
{
}
@property(nonatomic, strong) NSString *key_str;
@property(nonatomic, strong) NSString *value_str;
我的主要问题是苹果所说的 unconditionallyBridgeFromObjectiveC 是什么意思以及当应用程序中出现此类错误时如何调试。
编辑:-我已经粘贴了完整的崩溃日志
此崩溃表明 keywordsModel 类中的字符串属性之一为 nil,并且编译器需要 String! Objective C 中的
@property(nonatomic, strong) NSString *key_str;
相当于 Swift 中的 var key_str: String! { get set }
。