这是我的代码。有人可以解释如何在一步一步的方向修复它谢谢 我试图删除错误但它只会创建更多错误,如果有人可以帮助我会很感激
#import "ViewController.h"
@interface ViewController ()
@end
@interface ViewController ()
@end
@implementation ViewController
-(IBAction)number1:(id)sender{
Selectnumber = Selectnumber * 10;
Selectnumber = Selectnumber + 1;
screen.text = [NSString stringWithFormat:@"%i", Selectnumber];
}
-(IBAction)number2:(id)sender{
Selectnumber = Selectnumber * 10;
Selectnumber = Selectnumber + 2;
screen.text = [NSString stringWithFormat:@"%i",Selectnumber];
}
-(IBAction)number3:(id)sender{
Selectnumber = Selectnumber * 10;
Selectnumber = Selectnumber + 3;
screen.text = [NSString stringWithFormat:@"%i", Selectnumber];
}
-(IBAction)number4:(id)sender{
Selectnumber = Selectnumber * 10;
Selectnumber = Selectnumber + 4;
screen.text = [NSString stringWithFormat:@"%i", Selectnumber];
}
-(IBAction)number5:(id)sender{
Selectnumber = Selectnumber * 10;
Selectnumber = Selectnumber + 5;
screen.text = [NSString stringWithFormat:@"%i", Selectnumber];
}
-(IBAction)number6:(id)sender{
Selectnumber = Selectnumber * 10;
Selectnumber = Selectnumber + 6;
screen.text = [NSString stringWithFormat:@"%i", Selectnumber];
}
-(IBAction)number7:(id)sender{
Selectnumber = Selectnumber * 10;
Selectnumber = Selectnumber + 7;
screen.text = [NSString stringWithFormat:@"%i", Selectnumber];
}
-(IBAction)number8:(id)sender{
Selectnumber = Selectnumber * 10;
Selectnumber = Selectnumber + 8;
screen.text = [NSString stringWithFormat:@"%i", Selectnumber];
}
-(IBAction)number9:(id)sender{
Selectnumber = Selectnumber * 10;
Selectnumber = Selectnumber + 9;
screen.text = [NSString stringWithFormat:@"%i", Selectnumber];
}
-(IBAction)number0:(id)sender{
Selectnumber = Selectnumber * 10;
Selectnumber = Selectnumber + 0;
screen.text = [NSString stringWithFormat:@"%i", Selectnumber];
}
-(IBAction)Times:(id)sender{
if (Runningtotal ==0) {
Runningtotal = Selectnumber;
}
else{
switch (Method) {
case 1:
Runningtotal = Runningtotal* Selectnumber;
break;
case 2:
Runningtotal = Runningtotal / Selectnumber;
break;
case 3:
Runningtotal = Runningtotal - Selectnumber;
break;
case 4: Runningtotal = Runningtotal + Selectnumber;
break;
default:
break;
}
}
Method = 1;
Selectnumber = 0;
}
-(IBAction)devide:(id)sender{
if (Runningtotal ==0) {
Runningtotal = Selectnumber;
}
else{
switch (Method) {
case 1:
Runningtotal = Runningtotal* Selectnumber;
break;
case 2:
Runningtotal = Runningtotal / Selectnumber;
break;
case 3:
Runningtotal = Runningtotal - Selectnumber;
break;
case 4: Runningtotal = Runningtotal + Selectnumber;
break;
default:
break;
}
}
Method = 2;
Selectnumber = 0;
}
-(IBAction)Subtract:(id)sender{
if (Runningtotal ==0) {
Runningtotal = Selectnumber;
}
else{
switch (Method) {
case 1:
Runningtotal = Runningtotal* Selectnumber;
break;
case 2:
Runningtotal = Runningtotal / Selectnumber;
break;
case 3:
Runningtotal = Runningtotal - Selectnumber;
break;
case 4: Runningtotal = Runningtotal + Selectnumber;
break;
default:
break;
}
}
Method = 3;
Selectnumber = 0;
}
-(IBAction)Plus:(id)sender{
if (Runningtotal ==0) {
Runningtotal = Selectnumber;
}
else{
switch (Method) {
case 1:
Runningtotal = Runningtotal* Selectnumber;
break;
case 2:
Runningtotal = Runningtotal / Selectnumber;
break;
case 3:
Runningtotal = Runningtotal - Selectnumber;
break;
case 4: Runningtotal = Runningtotal + Selectnumber;
break;
default:
break;
}
}
Method = 4;
Selectnumber = 0;
}
-(IBAction)allclear:(id)sender{
Method = 0;
Runningtotal = 0;
Selectnumber = 0;
screen.text = [NSString stringWithFormat:@"0"];
}
-(IBAction)Equals:(id)sender{
if (Runningtotal ==0) {
Runningtotal = Selectnumber;
}
else{
switch (Method) {
case 1:
Runningtotal = Runningtotal* Selectnumber;
break;
case 2:
Runningtotal = Runningtotal / Selectnumber;
break;
case 3:
Runningtotal = Runningtotal - Selectnumber;
break;
case 4: Runningtotal = Runningtotal + Selectnumber;
break;
default:
break;
}
}
Method = 0;
Selectnumber = 0;
screen.text = [NSString stringWithFormat: @"%.2f", Runningtotal];
}
-(IBAction)percent:(id)sender {
}
-(IBAction)decimalpressed:(UIButton *)sender {
下一行是我遇到麻烦的地方:程序中意外的'@'
@implementation ViewController
-(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
} @end
这里是.h
#import <UIKit/UIKit.h>
int Method;
int Selectnumber;
float Runningtotal;
@interface ViewController : UIViewController
{
IBOutlet UILabel *screen;
}
-(IBAction)number1:(id)sender;
-(IBAction)number2:(id)sender;
-(IBAction)number3:(id)sender;
-(IBAction)number4:(id)sender;
-(IBAction)number5:(id)sender;
-(IBAction)number6:(id)sender;
-(IBAction)number7:(id)sender;
-(IBAction)number8:(id)sender;
-(IBAction)number9:(id)sender;
-(IBAction)number0:(id)sender;
-(IBAction)Times:(id)sender;
-(IBAction)devide:(id)sender;
-(IBAction)Subtract:(id)sender;
-(IBAction)Plus:(id)sender;
-(IBAction)Equals:(id)sender;
-(IBAction)allclear:(id)sender;
-(IBAction)decimalpressed:(id)sender;
-(IBAction)percent:(id)sender;
@end
答案 0 :(得分:1)
ViewDidLoad应为viewDidLoad
,小写&#34; v。&#34;另外我相信你有太多@end
陈述......