ozzotto
ozzotto

Reputation: 1196

UILabel [__NSCFString set]: unrecognized selector sent to instance crash

I am having a weird crash related to a UILabel but the crash reporting service I am using doesn't give me much help to locate it. I can't know which Controller and which UILabel is causing it. The only help I have is the following:

-[__NSCFString set]: unrecognized selector sent to instance 0x1e0958d0
0    CoreFoundation     __exceptionPreprocess + 162
1    libobjc.A.dylib    objc_exception_throw + 30
2    CoreFoundation     -[NSObject(NSObject) doesNotRecognizeSelector:] + 170
3    CoreFoundation     ___forwarding___ + 392
4    CoreFoundation     _CF_forwarding_prep_0 + 24
5    UIKit              -[UILabel _legacy_drawTextInRect:baselineCalculationOnly:] + 2632
6    UIKit              -[UILabel _drawTextInRect:baselineCalculationOnly:] + 166
7    UIKit              -[UILabel drawTextInRect:] + 450
8    UIKit              -[UILabel drawRect:] + 72
9    UIKit              -[UIView(CALayerDelegate) drawLayer:inContext:] + 364
10   QuartzCore         -[CALayer drawInContext:] + 112
11   QuartzCore         CABackingStoreUpdate_ + 1808
12   QuartzCore         CA::Layer::display_() + 980
13   QuartzCore         CA::Layer::display_if_needed(CA::Transaction*) + 202
14   QuartzCore         CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 24
15   QuartzCore         CA::Context::commit_transaction(CA::Transaction*) + 238
16   QuartzCore         CA::Transaction::commit() + 316
17   QuartzCore         CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 60
18   CoreFoundation     __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
19   CoreFoundation     __CFRunLoopDoObservers + 276
20   CoreFoundation     __CFRunLoopRun + 742
21   CoreFoundation     CFRunLoopRunSpecific + 356
22   CoreFoundation     CFRunLoopRunInMode + 104
23   GraphicsServices   GSEventRunModal + 74
24   UIKit              UIApplicationMain + 1120
25   App                main.m line 14
26   App                start + 40

Is there anything I can find my way through this? Thanx in advance!

Upvotes: 0

Views: 1398

Answers (3)

Mercurial
Mercurial

Reputation: 2165

Even though it's an old question, for anyone that encounters a similar issue:

If you're using attributedText in your UILabel, check the attribute value types you're setting. For example:

NSString* s = @"str";
NSMutableAttributedString* as = [[NSMutableAttributedString alloc] initWithString:s];
[as addAttribute:NSForegroundColorAttributeName value:someObjectThatsNotAUIColor range:NSMakeRange(0, s.length)];

will cause the UILabel [__NSCFString set]: unrecognized selector sent to instance crash.

Upvotes: 3

Cœur
Cœur

Reputation: 38667

You could try to put this in a .h :

@interface NSString (extended)
- (void)set;
@end

And this in a .m :

@implementation NSString (extended)
- (void)set
{
    NSLog(@"[NSString set] ??? impossible !!!");
}
@end

Then set a breakpoint on this method.

Upvotes: 1

jimpic
jimpic

Reputation: 5520

Search your project for " set]" then you'll probably already find it, as this is a very untypical method name. If that doesn't help, use NSLog to print out all your labels adresses to your console to find out which label is causing this. Like

for (UIView *sub in self.subviews)
    if ([sub kindOfClass:[UILabel class]]) NSLog(@"%p", sub);

(code untested, correct spelling if necessary)

Upvotes: 0

Related Questions