【发布时间】:2014-08-25 10:01:22
【问题描述】:
我正在尝试在我的新项目中使用 Parse SDK for iOS。它具有带有 enum 属性的 viewController;
typedef enum {
PFLogInFieldsNone = 0,
PFLogInFieldsUsernameAndPassword = 1 << 0,
PFLogInFieldsPasswordForgotten = 1 << 1,
PFLogInFieldsLogInButton = 1 << 2,
PFLogInFieldsFacebook = 1 << 3,
PFLogInFieldsTwitter = 1 << 4,
PFLogInFieldsSignUpButton = 1 << 5,
PFLogInFieldsDismissButton = 1 << 6,
PFLogInFieldsDefault = PFLogInFieldsUsernameAndPassword | PFLogInFieldsLogInButton | PFLogInFieldsSignUpButton | PFLogInFieldsPasswordForgotten | PFLogInFieldsDismissButton
} PFLogInFields;
根据 Objective-C 中的教程,我应该这样设置:
[logInViewController setFields: PFLogInFieldsTwitter | PFLogInFieldsFacebook | PFLogInFieldsDismissButton];
我正在尝试以这种方式(使用 swift):
loginViewController.fields = PFLogInFieldsTwitter | PFLogInFieldsFacebook | PFLogInFieldsDismissButton
但我收到错误:“'PFLogInFields' 不能转换为 'Bool'”
那么,设置此类属性的正确方法是什么?
【问题讨论】:
标签: objective-c enums swift parse-platform bit-masks