Search code examples
iosobjective-ciphoneios7ios8

iOS---Button causing unrecognized selector sent to instance 0x7f803a59cc50


I have 3 buttons in my view, one button can change the background color of words in text view and that one work fine.One button can change outline of words in text view.This one emerge error every time i click.

Here is my error:

libc++abi.dylib: terminating with uncaught exception of type NSException 
and Thread 1 : signal SIGABRT

And system do not know exactly which part crash,so i look into log navigator. Here is my log navigator log :

2015-01-21 17:42:04.482   Attributer[2592:79541] -[ViewController outlineBodySelection]: unrecognized selector sent to instance 0x7f803a59cc50
2015-01-21 17:42:04.485 Attributer[2592:79541] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController outlineBodySelection]: unrecognized selector sent to instance 0x7f803a59cc50'

Here is my code:

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UILabel *headline;
@property (weak, nonatomic) IBOutlet UITextView *body;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (IBAction)changeBodySelectionColourToMatchBackgroundOfButton:(UIButton *)sender {
    [self.body.textStorage addAttribute:NSForegroundColorAttributeName
                                  value:sender.backgroundColor
                                  range:self.body.selectedRange];
}


- (IBAction)outlineBodySelection
{
    [self.body.textStorage addAttributes:@{ NSStrokeWidthAttributeName : @-3,
                                            NSStrokeColorAttributeName : [UIColor blackColor] }range:self.body.selectedRange];
}

- (IBAction)unoutlineBodySelection
{
    [self.body.textStorage removeAttribute:NSStrokeWidthAttributeName range:self.body.selectedRange];
}
@end

I suppose the last two class emerge error,but where did it go wrong,how can i fix it? Somebody help me,please.


Solution

  • Every thing is ok from your side that i guess , but lets check once the connection from outlet whether from story board or XIB .

    may be some connection loss or wrong connection which has mention like ! mark

    else perfect from your side