如何解决 NSInternalInconsistencyException: 原因: '无效参数不满足: (name != nil) && ([name length] > 0)
Posted
技术标签:
【中文标题】如何解决 NSInternalInconsistencyException: 原因: \'无效参数不满足: (name != nil) && ([name length] > 0)\'【英文标题】:How to solve NSInternalInconsistencyException: reason: 'Invalid parameter not satisfying: (name != nil) && ([name length] > 0)'如何解决 NSInternalInconsistencyException: 原因: '无效参数不满足: (name != nil) && ([name length] > 0)' 【发布时间】:2021-06-22 08:08:00 【问题描述】:我在使用 OPPWAMobile 支付库时收到NSInternalInconsistencyException
。我需要以某种方式将name
传递给OPPPaymentSchemeViewController
,所以它将它传递给initWithNibName
。但我不确定如何在 Xcode 中做到这一点。
我已经检查了这个stack overflow solution,但它没有帮助,因为我没有直接访问视图控制器的权限。
我确定笔尖名称是某个属性文件的一部分,但我无法找到它。
关于如何做到这一点的任何想法?
2021-06-22 08:24:27.468604+0300 Runner[6738:85985] *** Assertion failure in -[UINib initWithNibName:directory:bundle:], UINib.m:97
2021-06-22 08:25:12.078452+0300 Runner[6738:85985] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: (name != nil) && ([name length] > 0)'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff20422fba __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007fff20193ff5 objc_exception_throw + 48
2 CoreFoundation 0x00007fff20422de3 +[NSException raise:format:] + 0
3 Foundation 0x00007fff207748e7 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
4 UIKitCore 0x00007fff242b63de -[UINib initWithNibName:directory:bundle:] + 309
5 UIKitCore 0x00007fff242b6489 +[UINib nibWithNibName:bundle:] + 76
6 OPPWAMobile 0x00000001067e9736 -[OPPPaymentSchemeViewController registerTableViewCellNibs] + 153
7 OPPWAMobile 0x00000001067e9389 -[OPPPaymentSchemeViewController viewDidLoad] + 157
8 UIKitCore 0x00007fff23f806a9 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 88
9 UIKitCore 0x00007fff23f8504c -[UIViewController loadViewIfRequired] + 1084
10 UIKitCore 0x00007fff23f85436 -[UIViewController view] + 27
11 UIKitCore 0x00007fff23ec6559 -[UINavigationController _preferredContentSizeForcingLoad:] + 198
12 UIKitCore 0x00007fff23e64354 -[UIPresentationController preferredContentSizeDidChangeForChildContentContainer:] + 64
13 UIKitCore 0x00007fff23e6018f __56-[UIPresentationController runTransitionForCurrentState]_block_invoke.466 + 178
14 UIKitCore 0x00007fff24bb1e36 -[_UIAfterCACommitBlock run] + 54
15 UIKitCore 0x00007fff246d01f8 _runAfterCACommitDeferredBlocks + 333
16 UIKitCore 0x00007fff246c01e4 _cleanUpAfterCAFlushAndRunDeferredBlocks + 221
17 UIKitCore 0x00007fff246f1a36 _afterCACommitHandler + 85
18 CoreFoundation 0x00007fff2038fd31 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
19 CoreFoundation 0x00007fff2038a542 __CFRunLoopDoObservers + 541
20 CoreFoundation 0x00007fff2038aaf5 __CFRunLoopRun + 1129
21 CoreFoundation 0x00007fff2038a1a7 CFRunLoopRunSpecific + 567
22 GraphicsServices 0x00007fff2b874d85 GSEventRunModal + 139
23 UIKitCore 0x00007fff246c14df -[UIApplication _run] + 912
24 UIKitCore 0x00007fff246c639c UIApplicationMain + 101
25 Runner 0x00000001064fec8b main + 75
26 libdyld.dylib 0x00007fff2025abbd start + 1
)
libc++abi: terminating with uncaught exception of2021-06-22 08:25:12.691736+0300 Runner[6738:88777] [] nw_protocol_get_quic_image_block_invoke dlopen libquic failed
type NSException
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: (name != nil) && ([name length] > 0)'
terminating with uncaught exception of type NSException
【问题讨论】:
在哪里?OPPWAMobile
是一个 xcframework。预编译并根据需要添加。我不能在代码中“传递”任何东西。我确定 OPPWAMobile 从属性文件中查找 name
值。但在哪里?
抱歉,我的错,错过了initWithNib:
部分
【参考方案1】:
我发现了问题。我需要在 Target->General->Frameworks, Libraries and Embedded Content 下将OPPWAMobile.xcframework
标记为“Embed & Sign”。
当我阅读Apple documentation 关于initWithNibName:bundle:
在nibName
为nil 时的行为方式时,我怀疑这可能是问题所在。
如果您为 nibName 参数指定 nil 并且您不覆盖 loadView 方法,视图控制器搜索 nib 文件为 在 nibName 属性中描述。
这意味着我遇到了异常,因为框架找不到必要的 nib 文件。
【讨论】:
以上是关于如何解决 NSInternalInconsistencyException: 原因: '无效参数不满足: (name != nil) && ([name length] > 0)的主要内容,如果未能解决你的问题,请参考以下文章