Swift 4你可以在结构中使用多维数组

时间:2018-02-14 05:48:49

标签: arrays swift struct

/*
// ORIGINAL C Code
#define SSIZEX 20
#define SSIZEY 13

typedef struct FCELL
{
    short Backdrop;
    char  Platform;
    char  DomiType;
    char  Spare[2];
}_FCELL;

typedef struct SCREENINFO
{
    charTheme[10];
    char    Tune[10];
    char    StartX;
    char    StartY;
    char    ExitX;
    char    ExitY;
    char    Author[4];
    char    Hints[4][5][16];
    char    TargetMins;
    char    TargetSecs;
    char    Keys[0x800];
}_SCREENINFO;

typedef struct  SCREEN
{
    FCELL       Screen[SSIZEY][SSIZEX];
    SCREENINFO  ScrInfo;
}_SCREEN;
*/

// Swift code
let SSIZEX          = 20
let SSIZEY          = 13

struct  _FCELL
{
    var Backdrop: Int
    var Platform: Int
    var DomiType: Int
    var Spare:    Int
}
struct  _SCREENINFO
{
    var Theme:       String
    var Tune:        String
    var StartX:      Int
    var StartY:      Int
    var ExitX:       Int
    var ExitY:       Int
    var Author:      String
    var Hint:        String
    var TargetMins:  Int
    var TargetSecs:  Int
    var Keys:        String
}
struct _SCREEN
{
}

您好 我有原始的C代码(上图),我试图转换为Swift 4。 FCELL& _SCREENINFO很容易转换,但我很难尝试制作_SCREEN结构。可能吗 ? 我希望尽可能接近原始版本,以便对代码的其余部分进行最小化更改。

0 个答案:

没有答案