Method cannot be a member of an @objc protocol because the type of the parameter 4 cannot be repr...

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 @objc protocol because the type of the parameter 4 cannot be repr...)