简体   繁体   中英

Reference to enum is ambiguous objective-c

I defined a NS_ENUM below in another file:

typedef NS_ENUM (NSUInteger, LinkPlatformType){
    LinkPlatformTypeEmail = 1,
    LinkPlatformTypeFacebook,
    LinkPlatformTypeGoogle
};

When I try to do a switch case:

- (void)linkWithType:(LinkPlatformType)linkType {
    switch (linkType) {
        case LinkPlatformTypeGoogle:
            break;
        case LinkPlatformTypeFacebook:
            break;
        default:
            break;
    }
}

I am getting a build error: Reference to LinkPlatformTypeGoogle is ambiguous . Reference to LinkPlatformTypeFacebook is ambiguous .

Updates:

The file defines.h which i defined the enum is in for example Target 1, And there is a Class StoreClass which import this defines.h file. And the StoreClass.m Target Membership I have set as multiple targets: Target 1 and Target 2. So after I do this, the Reference to LinkPlatformTypeFacebook is ambiguous appeared. Will this be the reason?

Changing the import from

#import "SwipeView.h"

to

@import SwipeView;

worked for me

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