iphone - Xcode中的各种奇数错误

标签 iphone objective-c xcode xcode4 compiler-errors

在Xcode中,我遇到了一些应该正常生成的奇数错误。

首先,在

- (void)touchesMoved:(NSSet *)touches withEvent(UIEvent *)event {
    [self touchesBegan:touches withEvent:event];
    marblebeingdragged = NO;
}

它给了我错误:
error: Semantic Issue: Use of undeclared identifier 'touchesMoved'
in the first line: `expected ';' before ':' token`

另外,在我的switch语句中:(请注意case和break语句中注释的错误)
switch (marblecolor) {    
    case 1: //Aqua
        plusone.image = [UIImage imageNamed: @"Aqua/+1"]; //Parse Issue: Extraneous ']' before ';'

        plustwo.image = [UIImage imageNamed: @"Aqua/+2"];
        plusthree.image = [UIImage imageNamed: @"Aqua/+3"];
        minusone.image = [UIImage imageNamed: @"Aqua/-1"];
        minustwo.image = [UIImage imageNamed: @"Aqua/-2"];
        minusthree.image = [UIImage imageNamed: @"Aqua/-3"];
            break; //Semantic Issue: 'break' statement not in loop or switch statement

    case 2: //Blue //Semantic Issue: 'case' statement not in switch statement
        plusone.image = [UIImage imageNamed: @"Blue/+1"];
        plustwo.image = [UIImage imageNamed: @"Blue/+2"];
        plusthree.image = [UIImage imageNamed: @"Blue/+3"];
        minusone.image = [UIImage imageNamed: @"Blue/-1"];
        minustwo.image = [UIImage imageNamed: @"Blue/-2"];
        minusthree.image = [UIImage imageNamed: @"Blue/-3"];
        break; //Semantic Issue: 'break' statement not in loop or switch statement

    case 3: //Green //Semantic Issue: 'case' statement not in switch statement
        plusone.image = [UIImage imageNamed: @"Green/+1"];
        plustwo.image = [UIImage imageNamed: @"Green/+2"];
        plusthree.image = [UIImage imageNamed: @"Green/+3"];
        minusone.image = [UIImage imageNamed: @"Green/-1"];
        minustwo.image = [UIImage imageNamed: @"Green/-2"];
        minusthree.image = [UIImage imageNamed: @"Green/-3"];
            break; //Semantic Issue: 'break' statement not in loop or switch statement

    case 4: //Semantic Issue: 'case' statement not in switch statement
        plusone.image = [UIImage imageNamed: @"Grey/+1"];
        plustwo.image = [UIImage imageNamed: @"Grey/+2"];
        plusthree.image = [UIImage imageNamed: @"Grey/+3"];
        minusone.image = [UIImage imageNamed: @"Grey/-1"];
        minustwo.image = [UIImage imageNamed: @"Grey/-2"];
        minusthree.image = [UIImage imageNamed: @"Grey/-3"];
            break; //Semantic Issue: 'break' statement not in loop or switch statement

    case 5: //Pink //Semantic Issue: 'case' statement not in switch statement
        plusone.image = [UIImage imageNamed: @"Pink/+1"];
        plustwo.image = [UIImage imageNamed: @"Pink/+2"];
        plusthree.image = [UIImage imageNamed: @"Pink/+3"];
        minusone.image = [UIImage imageNamed: @"Pink/-1"];
        minustwo.image = [UIImage imageNamed: @"Pink/-2"];
        minusthree.image = [UIImage imageNamed: @"Pink/-3"];
            break;
}

最后,在我的@end中给出了错误:expected declaration or statement at end of input

有关错误的任何线索?

最佳答案

对于初学者,您的- (void)touchesMoved:(NSSet *)touches withEvent(UIEvent *)event {行在withEvent之后需要一个冒号,因此它应该是- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {

解决此问题,我们将看看有什么用。 (编辑:查看您的其他错误,在您修复方法声明拼写错误后,它们可能会消失。我当然希望@end错误会消失。)

关于iphone - Xcode中的各种奇数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7626983/

相关文章:

ios - 尝试访问分段控制索引时,Swift 抛出错误

iphone - UITextView 对齐方式正在自行更改

ios - 内存中的 AVAudioFile?

iphone - 在 UITableView 单元格中格式化日期和时间

objective-c - 实现复制方法 - 复制整行

ios - 如何在 iOS 应用程序中评论 instagram 提要

ios - 从 didFinishLaunchingWithOptions 打开 ViewController

ios - Obj-C 添加项目依赖但主项目找不到头文件

iphone - 如何使用特定名称保存 UIImagePicker 图像

ios - 文件目录中的图像路径替换