Xcode告诉我,我有一个"不完整的实现"

Chr*_*on4 1 xcode implementation objective-c

我的老师给了我这个main.m,我必须编写.h和.m方法.在我的.m(非主要)文件中,我收到了来自Xcode的"不完整实现"警告.我为所有被调用的方法制定了方法,所以我无法弄清楚它为什么这么说.以下是我无法修改的代码:

#import <Foundation/Foundation.h>
#import "ChutesAndLadders.h"
int main(int argc, const char * argv[])
{
    @autoreleasepool {
        ChutesAndLadders *cl = [[ChutesAndLadders alloc]init];
        [cl initBoard];
        [cl makeChutes:10];
        [cl makeLadders:10]
        int chutes=0;
        int ladders=0;
        for(int i=0;i<cl.board.count;i++){
            NSString * cell = (NSString *)[cl.board objectAtIndex:i];
            int additionalSpaces = (int)[cl addToMove:cell];
            if(additionalSpaces>0)
                ladders++;
            else if (additionalSpaces<0)
                chutes++;
        }
        [cl printBoard];
    }
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

这是我编码的.h,我相信它没关系:

#import <Foundation/Foundation.h>
@interface ChutesAndLadders : NSObject{
    @private
    NSMutableArray * board;
}
@property (readwrite, retain) NSMutableArray *board;
-(id) initBoard;
-(NSString *)addToMove: (NSString *) cell;
-(void)makeChutes: (int) length;
-(void)makeLadders: (int) length;
-(void)printBoard;
@end
Run Code Online (Sandbox Code Playgroud)

这是我的.m,这是我在"@implementation ChutesAndLadders"行中遇到问题的地方:

#import "ChutesAndLadders.h"
@implementation ChutesAndLadders//incomplete impementation????????????
@synthesize board=_board;
-(void) initBoard{
    //self = [super init];
    //if (self){
        _board = [board initWithCapacity: 100];
        //self._board=[[NSMutableArray alloc]initWithCapacity:100];
        for(int i =0; i < 100; i++){
            [_board addObject:@""];
        //}
    }
}
-(void)makeChutes: (int) length {
    //Make argument number of Chutes randomly across the board.
    for(int i = 0; i < length;){
        int random = arc4random_uniform(101);
        if ([[_board objectAtIndex:random] isEqual:@""]) {
            NSString *fString = [NSString stringWithFormat:@"C%d", length];
            [_board replaceObjectAtIndex:random withObject:fString];
            i++;
        }
    }
}
-(void)makeLadders: (int) length {
    //Make argument number of Ladders randomly across the board.
     for(int i = 0; i < length;){
        int random = arc4random_uniform(101);
        if ([[_board objectAtIndex:random] isEqual:@""]) {
                NSString *fString = [NSString stringWithFormat:@"L%d", length];
            [_board replaceObjectAtIndex:random withObject:fString];
            i++;
        }
    }
}
-(NSString *)addToMove: (NSString*) cell {
    if([[_board objectAtIndex:[cell integerValue]] isEqualToString:@"C10"]){
        return (@"-10");
     }
    if([[_board objectAtIndex:[cell integerValue]] isEqualToString:@"L10"]){
        return (@"10");
    }
     else
        return (@"0"); 
}
-(void) printboard {
    //Print the board in rows of 10 so that it looks like a square in console.
    for(int i=0; i < (_board.count/10); i++){
        for(int j = 0; j < 10; j++){
            NSLog(@"|");
            NSLog(@"%@", [_board objectAtIndex:(i+j)]);
            NSLog(@"|");
        }
        NSLog(@"\n");
    }
}
@end
Run Code Online (Sandbox Code Playgroud)

这是我在Objective-C中的第一个任务,一般就Mac来说,我已经有一段时间了,主要是研究/学习,我只是看不出我做错了什么.

我没有运行这个程序,所以对于你可能看到的任何其他愚蠢的错误感到抱歉,一旦我真的可以把它输出到控制台,我会弄明白它,所以我可以看看它是否正在做它想要的.

小智 5

通过左上角的三角形/感叹号按钮打开"问题"导航器:

在此输入图像描述

如果您使用左边的小三角形展开"不完整实现"语义问题,您可以看到XCode投诉的详细信息.