简体   繁体   English

应用程序因错误而崩溃:-[NSNull 长度]:无法识别的选择器发送到实例

[英]App crashing with error: -[NSNull length]: unrecognized selector sent to instance

This line [self.label setFont:[MyUtilityClass fontWithSize:13.0f]];这一行[self.label setFont:[MyUtilityClass fontWithSize:13.0f]]; of code is giving me the -[NSNull length]: crash.代码给了我 -[NSNull length]: 崩溃。 label as many of you guys can guess is a UILabel.很多人都能猜到的label是 UILabel。 The only logical explanation I can think of is UILabel text is null.我能想到的唯一合乎逻辑的解释是 UILabel 文本为空。 I will post my utility class below just in case it helps.我将在下面发布我的实用程序类,以防万一。

MyUtilityClass我的实用程序类

 + (UIFont *) fontWithSize : (CGFloat) size
   {
UIFont *font = [UIFont fontWithName:@"Roboto-Regular" size:size];

return font;
    }

edit: This is the error message I've received.编辑:这是我收到的错误消息。 I can copy and paste the raw data if you need me to.如果您需要,我可以复制和粘贴原始数据。 This is a crash a user received according to crashlytics.这是用户根据 crashlytics 收到的崩溃。

Fatal Exception: NSInvalidArgumentException致命异常:NSInvalidArgumentException

  -[NSNull length]: unrecognized selector sent to instance 0x378e23f0

This is the raw data of the crash.这是崩溃的原始数据。

Thread : Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x297c3c1f __exceptionPreprocess + 126
1  libobjc.A.dylib                0x36f97c8b objc_exception_throw + 38
2  CoreFoundation                 0x297c9039 __methodDescriptionForSelector
3  CoreFoundation                 0x297c6f57 ___forwarding___ + 714
4  CoreFoundation                 0x296f8df8 _CF_forwarding_prep_0 + 24
5  UIKit                          0x2cc8b1b5 -[UILabel _setFont:] + 100
6  MyApp                        0x00137c29 -[MyViewController initUI] (MyViewController.m:90)
7  MyApp                       0x0013765b -[MyViewController viewDidLoad] (MyViewController.m:51)
8  UIKit                          0x2cc82f8f -[UIViewController loadViewIfRequired] + 602
9  UIKit                          0x2cd2cd95 -[UINavigationController _layoutViewController:] + 32
10 UIKit                          0x2cd2ccbd -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 228
11 UIKit                          0x2cd2c253 -[UINavigationController _startTransition:fromViewController:toViewController:] + 74
12 UIKit                          0x2cd2bf83 -[UINavigationController _startDeferredTransitionIfNeeded:] + 578
13 UIKit                          0x2cd2bced -[UINavigationController __viewWillLayoutSubviews] + 44
14 UIKit                          0x2cd2bc81 -[UILayoutContainerView layoutSubviews] + 184
15 UIKit                          0x2cc804d7 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 514
16 QuartzCore                     0x2c6a8a0d -[CALayer layoutSublayers] + 136
17 QuartzCore                     0x2c6a43e5 CA::Layer::layout_if_needed(CA::Transaction*) + 360
18 QuartzCore                     0x2c6a426d CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 16
19 QuartzCore                     0x2c6a3c51 CA::Context::commit_transaction(CA::Transaction*) + 224
20 QuartzCore                     0x2c6a3a55 CA::Transaction::commit() + 324
21 UIKit                          0x2cc78965 _afterCACommitHandler + 132
22 CoreFoundation                 0x2978a3b5 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
23 CoreFoundation                 0x29787a73 __CFRunLoopDoObservers + 278
24 CoreFoundation                 0x29787e7b __CFRunLoopRun + 914
25 CoreFoundation                 0x296d6211 CFRunLoopRunSpecific + 476
26 CoreFoundation                 0x296d6023 CFRunLoopRunInMode + 106
27 GraphicsServices               0x30a8f0a9 GSEventRunModal + 136
28 UIKit                          0x2cce21d1 UIApplicationMain + 1440
29 MyApp                        0x000a07e7 main (main.m:16)
30 libdyld.dylib                  0x37517aaf start + 2

您很可能试图获得您认为是NSString但实际上是NSNull

I got this issue with my code & resolved it by using system fonts.我的代码遇到了这个问题并通过使用系统字体解决了它。 The case was it couldn't load the font which I had specified into the code.情况是它无法加载我在代码中指定的字体。 Try & let me know if it help.尝试并让我知道它是否有帮助。

Happy Coding, cheers, Ratneshwar快乐编码,干杯,Ratneshwar

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 -[NSNull 长度]:无法识别的选择器发送到实例 - -[NSNull length]: unrecognized selector sent to instance NSInvalidArgumentException-[NSNull长度]:无法识别的选择器已发送到实例 - NSInvalidArgumentException -[NSNull length]: unrecognized selector sent to instance [NSNull length]:无法识别的选择器已发送到实例 - [NSNull length]: unrecognized selector sent to instance [NSNull长度]:无法通过键盘按键发送到实例的选择器? - [NSNull length]: unrecognized selector sent to instance on keyboard keystroke? iOS 8可以运行,但iOS 7会因-[NSNull长度]而崩溃:无法识别的选择器已发送到实例 - iOS 8 works but iOS 7 crashes with -[NSNull length]: unrecognized selector sent to instance iOS和Stackmob - [NSNull length]:发送到实例的无法识别的选择器 - iOS & Stackmob - [NSNull length]: unrecognized selector sent to instance NSInvalidArgumentException',原因:'-[NSNull 长度]:无法识别的选择器发送到实例 - NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance 由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'-[NSNull长度]:无法识别的选择器已发送到实例 - Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance Flutter flutter_webview_plugin 错误 [NSNull 长度]:无法识别的选择器发送到 ios 上的实例 - Flutter flutter_webview_plugin error [NSNull length]: unrecognized selector sent to instance on ios -[NSNull长度]:无法识别的选择器发送到JSON对象 - -[NSNull length]: unrecognized selector sent to JSON objects
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM