1

我有以下代码:

switch (self.status) {
    case refused:
        message=NSLocalizedString(@"booking refused", nil);
        break;
    case accepted:
        message=NSLocalizedString(@"booking accepted", nil);
        break;
    case taxiAborted:
        message=NSLocalizedString(@"booking aborted", nil);
        break;
    case near:
        message=NSLocalizedString(@"booking aborted", nil);
        break;
    case completed:
        message=NSLocalizedString(@"booking completed", nil);
        break;
    default:
        break;
}

永远不会进入开关内部:既没有达到默认情况,也没有达到正确的值。在我的例子中,self.status 的值为“active”,它是以下枚举的一部分:

typedef enum {
requested = 0,
refused = 1,
    accepted =2,
    taxiAborted=3,
    near = 4,
    running= 5,
    completed = 6,
    userAborted=7
} statuses;

我做错了什么?

4

0 回答 0