简体   繁体   中英

How to declare a typedef enum of structs in Objective-C if possible

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;

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

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};
...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM