Search code examples
objective-cios6uitextfieldnsmutableattributedstring

-[NSConcreteMutableAttributedString _UIKBStringWideAttributeValueForKey:]: message sent to deallocated instance 0x11ba0740


I have an app where app is getting crashed when I click on textfield in iOS6. The crash occurs saying below message.

-[NSConcreteMutableAttributedString _UIKBStringWideAttributeValueForKey:]: message sent to deallocated instance 0x11ba0740

I have an app with English and Arabic version. For arabic, I am using NSMutableAttributedString and set text as textField.attributedText

It works fine with iOS 7. Problem is with iOS 6 only.


Solution

  • Not sure what is the problem, but below is how I solved.

    in viewDidLoad I added below.

    [fullName addTarget:self action:@selector(handleTouchValueChangedUN) forControlEvents: UIControlEventEditingDidEnd];
    

    Then used handleTouchValueChangedUN as below.

    -(void) handleTouchValueChangedUN {
        [User_FullName setString:fullName.text];
    }
    

    AddedtextFieldShouldBeginEditing where I set text as blank and then set its value to its actual value.

    - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
    {
    
        textField.text = @"";
        if (textField==fullName) {
            attributedString = [[NSMutableAttributedString alloc] initWithString:User_FullName attributes:@{ NSFontAttributeName : [UIFont fontWithName:localize(@"myFontName") size:[localize(@"fontSize001") floatValue]], NSLigatureAttributeName: @2}];
            textField.attributedText = attributedString;
        }
    
        return YES;
    }
    

    However I am more concerned for this as this never happened to me before. This is first time I am experiencing.