编译器警告(1):完全执行未完成的实现和指针转换错误。
我比我的.h和.m文件,看看什么申报和实施,并不能找到任何之间的任何不一致或拼写错误。
编译器警告(2):指针转换发送'NSInteger *'(又名'int *')与'int'类型的表达式不兼容的整数。
我一直在用各种组合的星号25分钟,编译器仍然不高兴。
#import "Game.h"
#import "stdlib.h"
const int MAXRAND = 15;
const int MAXCOL = 7;
const int MAXROW = 9;
NSInteger gameState[MAXROW][MAXCOL];
NSInteger answerBoard[MAXROW][MAXCOL];
@implementation Game//compiler warning 1
-(void)init:(NSInteger*) rows: (NSInteger*) columns: (NSInteger*) operators:(NSInteger*) operands{
NSLog(@"init sent");
numRows = *rows;
numColumns = *columns;
numOperators = *operators;
numOperands = *operands;
//seed random number generator
//generate rand nums for operands
int operandList[numOperands];
for (int i = 0; i < numOperands; i++) {
srandom(time(NULL));
operandList[i] = (random()%MAXRAND);
}
//generate state and answer board
BOOL gameState[numRows][numColumns];
NSInteger answerBoard[numRows][numColumns];
for (int i = 0; i < numRows; i++) {
for (int j = 0; j < numColumns; j++) {
gameState[i][j] = NO;
answerBoard[i][j] = (operandList[random()%numOperands])+
(operandList[random()%numOperands])-
(operandList[random()%numOperands]);
}
}
}
-(void)updateGame:(NSInteger*)enteredNum{
NSLog(@"updateGame sent");
for (int i = numColumns; i > 0; i--) {
for (int j = numRows; j > 0; j--) {
if (gameState[i][j] == NO){
if (*enteredNum == answerBoard[i][j]){
gameState[i][j] = YES;
}
}
}
}
}
@end//Game
#import <Foundation/Foundation.h>
@interface Game : NSObject
{
NSInteger numRows, numColumns, numOperators, numOperands;
}
-(void)init:(NSInteger*) rows: (NSInteger*) columns: (NSInteger*) operators:(NSInteger*) operands;
-(void)updateGame:(NSInteger*) enteredNum;
@end
凡我类的实例声明和初始化:
NSInteger *rows = 7, *columns = 6, *operators = 2, *operands = 6;//compiler warning 2
Game *game = [Game new];
[game init:rows :columns :operators :operands];
此致,您需要对C编程语言的基本要点进行回顾。 – ZhangChn 2012-02-19 16:37:59
我试图编译你的代码在一个测试项目,它的工作..试图清除你的项目 – 2012-02-19 16:56:44