Equality on Objective-C typedef enum in Swift

前端 未结 4 735
误落风尘
误落风尘 2021-02-19 08:01

I\'m working with the Facebook Objective-C SDK in Swift and I\'m trying to compare an FBSessionState value with a value from the enum. However I get the compiler error:

4条回答
  •  温柔的废话
    2021-02-19 08:34

    With the Beta4 update, the .value workaround no longer works. There doesn't seem to be another easy workaround without changing Facebook's SDK.

    I changed all the Facebook enums to use the NS_ENUM macro, so that you can use Swift syntax the enums.

    if FBSession.activeSession().state == .CreatedTokenLoaded
    

    These changes were merged into pgaspar's Facebook fork, which includes other fixes for Swift compatibility.

    pod 'Facebook-iOS-SDK', :git => 'https://github.com/pgaspar/facebook-ios-sdk.git'
    

提交回复
热议问题