我有这个应用程序允许用户点击一个页面上的按钮,这将增加一个整数的计数,但是在另一个页面上它应该加起来两个整数并给出它们的总和。我已经得到了编译的代码,但我没有看到它绊倒自己的位置,生病了下面的错误日志,但如果有人可以帮助那将是惊人的!
错误日志
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 :(得分:0)
你的功能定义应该是
-(IBAction)totalcount:(id)sender;
在FirstViewController.h中