1

This is extremely odd! Its simple stuff which is why i cannot understand. Below shows my class.

#import <UIKit/UIKit.h>

@interface LogInViewController : UIViewController
- (IBAction)loginButtonPressed:(id)sender;

@end

.

#import "LogInViewController.h"

@interface LogInViewController ()

@end

@implementation LogInViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

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

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


//

- (IBAction)loginButtonPressed:(id)sender
{
    NSLog(@"login Button Pressed");
}

Whenever i click the button though it throws this?!

loginButtonPressed:]: unrecognized selector sent to instance 0x15e3bf60 2013-10-28 11:23:24.249 Headache Mbl[1352:60b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSSetM loginButtonPressed:]: unrecognized selector sent to instance 0x15e3bf60' * First throw call stack:

Ive checked and the button is correctly sending the "touch up inside to loginButtonPressed:"

Help!, Thankyou:)

Here is how i attach the view controller to my main screen

import

@interface ViewController : UIViewController

@property (strong) IBOutlet UIView *loginView;

.

- (void)viewDidLoad
{

    LogInViewController *logIn = [[LogInViewController alloc] initWithNibName:@"LogInViewController" bundle:nil];
    [self.loginView addSubview:logIn.view];
    [self.loginView setClipsToBounds:YES];
}
Fudgey
  • 3,793
  • 7
  • 32
  • 53
  • Are you using ARC ? . Take a look at this question http://stackoverflow.com/questions/2455161/unrecognized-selector-sent-to-instance?rq=1 – Priyatham51 Oct 28 '13 at 11:43
  • And also right on your button and see if it is connected to only one `IBAction`. If you have changed method names it might be still pointing to the old name. – Priyatham51 Oct 28 '13 at 11:51
  • pls show your code that declaring the object for LogInViewController – manujmv Oct 28 '13 at 11:58
  • Iv added the code above that shows me attaching the nib to my uiview in my mainviewcontroller, thanks – Fudgey Oct 28 '13 at 13:09
  • i have checked the the button is definitely wired up to the correct method :) – Fudgey Oct 28 '13 at 13:12

2 Answers2

1

Looks like memory issues. If you are using ARC you should keep strong reference to view controller. If you are using manual memory management probably view controller has been overreleased. To find issues you can add NSZombieEnabled flag to scheme or use Instruments with Zombie.

Roman Kabachenko
  • 513
  • 2
  • 10
  • Hi, I am using ARC and have used a strong reference to the uiview, is this what you meant. iv edit the post above to show this, as well as how i set up the mainscreen. Thanks – Fudgey Oct 28 '13 at 13:08
  • @Ryan No he means maintain a strong reference to the view **controller** i.e.e the class you have shown in your question. – JeremyP Oct 28 '13 at 15:20
0

Just a proposal, but did you check the event connections of the button in IB. May you left connection to another VC in which you've deleted the action method. Check in the console loginButtonPressed:]: unrecognized selector sent to instance 0x15e3bf60 what is 0x15e3bf60 (po 0x15e3bf60).

vhristoskov
  • 2,074
  • 2
  • 16
  • 20