2011-11-04 79 views
0

通过在Xcode中创建小型控制台游戏来学习Objective C。我目前正在制作一种战舰网格游戏。玩家通过scanF输入坐标而不是通过箭头键实现方法?我检查过苹果文档,但找不到任何类方法。使用箭头键在控制台应用程序中导航

这是我的代码,我希望玩家方便浏览:

NSMutableArray *theBoard = [[NSMutableArray alloc]init]; 
for (int i = 1; i < 101; i++) { 
    [theBoard addObject:[NSString stringWithFormat:@"%02d",i]]; 
} 

// this prints the board to console 
for (int i = 0; i < 10; i++) { 
    NSLog(@"  %@",[[theBoard subarrayWithRange:NSMakeRange(0+(i*10) , 10)]componentsJoinedByString:@" "]); 
} 

回答

1

Mac OS X包含Ncurses,这是一个用于创建基于控制台的UI一个有用的库。