引用枚举是不明确的目标c [英] Reference to enum is ambiguous objective-c

查看:261
本文介绍了引用枚举是不明确的目标c的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在另一个文件中定义了一个NS_ENUM:

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

当我尝试做一个开关案例:



($)$($)$($)$($)$($)$($)$($)$ {
$
case LinkPlatformTypeFacebook:
break;
默认值:
break;
}
}

我收到构建错误:引用LinkPlatformTypeGoogle是不明确的参考LinkPlatformTypeFacebook是不明确的



更新:



我定义了枚举的文件define.h,例如目标1,还有一个ClassClassClass导入这个define.h文件。而StoreClass.m目标成员资格我已经设置为多个目标:目标1和目标2.所以在我这样做之后,$ code引用到LinkPlatformTypeFacebook是不明确的/ / code>出现。这是否是原因?

解决方案

更改导入

  #importSwipeView.h

to

  @import SwipeView; 

为我工作


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

这篇关于引用枚举是不明确的目标c的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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