質問

I'm using cool lib FontAwesomeKit (https://github.com/PrideChung/FontAwesomeKit) for my new iOS app. But I'm stuck with strange exception it's throwing only on Release mode and my iPhone with iOS 7.1.1.

It looks like:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: 'NSConcreteMutableAttributedString addAttribute:value:range:: nil value'

When I test in simulator (both DEBUG and RELEASE) and iPhone (DEBUG) everything works fine, iPhone (RELEASE) crashes.

This workaround didn't help - https://github.com/PrideChung/FontAwesomeKit/blob/master/KnownIssues.md

Thanks!

UPDATE

The problem was in my code and __weak reference:

__weak UIColor *menuColor = [UIColor colorWithHexString:@"#636577"];
__weak UIColor *menuColorHover = [UIColor colorWithHexString:@"#3D3F52"];
CGFloat icon_size = 25.5f;

for (UIButton *button in self.buttons) {
    if ([button.titleLabel.text isEqualToString:@"Feed"]) {
        FAKFoundationIcons *feedIcon = [FAKFoundationIcons homeIconWithSize:icon_size];

        [feedIcon addAttribute:NSForegroundColorAttributeName value:menuColor];
        [button setImage:[feedIcon imageWithSize:CGSizeMake(icon_size, icon_size)] forState:UIControlStateNormal];

        [feedIcon addAttribute:NSForegroundColorAttributeName value:menuColorHover];
        [button setImage:[feedIcon imageWithSize:CGSizeMake(icon_size, icon_size)] forState:UIControlStateHighlighted];
    }
役に立ちましたか?

解決

You don't need __weak there.

As you said in the comments, it worked in debug builds since no optimizations were in place, but in release builds the compiler decided to optimize away the weak references, leaving you with nil passed as an argument.

Just get rid of the unnecessary __weak modifier and you'll be good.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top