如何申报在Objective-C如果可能的结构的typedef枚举 [英] How to declare a typedef enum of structs in Objective-C if possible

查看:125
本文介绍了如何申报在Objective-C如果可能的结构的typedef枚举的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在为了能够限制位置可用位置的列表,我尝试了以下声明:

In order to be able to limit the positions to a list of available positions I tried the following declaration:

typedef enum
{
    feedbackPositionMiddle = {20.f,80.f},
    feedBackPositionTop    = {20.f,40.f},
    feedBackPositionBottom = {20.f,120.f}

} feedBackPosition;

然而,这code似乎并不被接受。它是否错过的东西,或只是不可能?

However this code does not seems to be accepted. Does it misses something or is it just impossible?

推荐答案

您可以只声明整数类型,因此结构或任何其他类型的复合这里不允许枚举的。你的情况常量CGPoint可能是最好的选择:

You can declare enum only of integral type, so struct or any other composite type is not allowed here. In your case const CGPoint is probably the best option:

const CGPoint kFeedbackPositionMiddle = {20.f,80.f};
...

这篇关于如何申报在Objective-C如果可能的结构的typedef枚举的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆