0

Ive got this app that allows a user to click on a button on one page which will increase the count of a integer however on the other page it should add up two integers and give the sum of them. Ive got the code to compile but I don't see where its tripping over its self, ill post the error log below but if anyone can help that would be amazing!

error log

2013-07-07 16:20:12.126 Ride Count BETA[10425:c07] -[FirstViewController totalcount]: unrecognized selector sent to instance 0x7664960
2013-07-07 16:20:12.128 Ride Count BETA[10425:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FirstViewController totalcount]: unrecognized selector sent to instance 0x7664960'
*** First throw call stack:
(0x1cc2012 0x10ffe7e 0x1d4d4bd 0x1cb1bbc 0x1cb194e 0x1113705 0x472c0 0x47258 0x108021 0x10857f 0x1076e8 0x76cef 0x76f02 0x54d4a 0x46698 0x1c1ddf9 0x1c1dad0 0x1c37bf5 0x1c37962 0x1c68bb6 0x1c67f44 0x1c67e1b 0x1c1c7e3 0x1c1c668 0x43ffc 0x22cd 0x21f5)
libc++abi.dylib: terminate called throwing an exception

view controller.h

//  FirstViewController.h
//  Ride Count BETA
//
//  Created by James on 05/07/2013.
//  Copyright (c) 2013 James. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "SecondViewController.h"

int Count;


@interface FirstViewController : UIViewController{
    IBOutlet UILabel *label;

    IBOutlet UILabel *total;

}

-(IBAction) generateNumbers;

-(IBAction) totalcount;

@end

View controller.m

//
//  FirstViewController.m
//  Ride Count BETA
//
//  Created by James on 05/07/2013.
//  Copyright (c) 2013 James. All rights reserved.
//

#import "FirstViewController.h"

@interface FirstViewController ()

@end

@implementation FirstViewController

//adding up all the rides

-(IBAction)totalcount:(id)sender{

    //adding two integers from another .h file
    Count=Alton+Alton2;
    total.text = [NSString stringWithFormat:@"You've been on %i rides", Count];
}

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

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

@end
4

1 回答 1

0

your function definition should be

-(IBAction)totalcount:(id)sender;

in FirstViewController.h

于 2013-07-07T15:31:36.983 回答