2013-07-07 20 views
0

我已经有了这个应用程序,允许用户点击一个页面上的按钮,这将增加一个整数的计数,但在另一个页面上它应该加起来两个整数并给出它们的总和。我得到了代码编译,但我没有看到它的自我跳动的位置,生病发布在下面的错误日志,但如果任何人都可以帮助,这将是惊人的!应用程序落在某处

错误日志

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 

视图或者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 

查看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 

回答

0

您函数的定义应该是

-(IBAction)totalcount:(id)sender; 
在FirstViewController.h