美文网首页iOS倒计时
Method cannot be a member of an

Method cannot be a member of an

作者: 铁汁红豆 | 来源:发表于2022-08-25 14:22 被阅读0次

Swift option错误Method cannot be a member of an @objc protocol because the type of the parameter 2 cannot be represented in Objective-C解决方法

在swift中protocol如果要用optional的话必须在protocol前加@objc,比如说

 enum moreType {

    case  moreshowUnBtnMoreType

    case  moreNoUnBtnMoreType

    case  unBtnMoreType

}

Method cannot be a member of an @objc protocol because the type of the parameter 2 cannot be represented in Objective-C“`

是因为该方法中的枚举moreType没有@objc,在moreType前加上@objc,并加上raw type:Int就可以了

@objc enum moreType:Int{

    case  moreshowUnBtnMoreType

    case  moreNoUnBtnMoreType

    case  unBtnMoreType

}

相关文章

网友评论

    本文标题:Method cannot be a member of an

    本文链接:https://www.haomeiwen.com/subject/uaaagrtx.html