1
我在使用Philips Hue SDK(在Swift中使用Bridge頭文件導入的Obj-C框架)枚舉比較方面存在問題。在Swift中不能正常工作的目標C類型def enum的比較
這是對象 - 枚舉:
/*******************************************************************************
Copyright (c) 2013-2014 Koninklijke Philips N.V.
All Rights Reserved.
********************************************************************************/
#define SDK_ERROR_DOMAIN @"com.philips.hue.sdk"
typedef enum {
// Resource parsers
INVALID_JSON = 1,
INVALID_ARGUMENTS = 2,
// PHHttpRequester
NO_CONNECTION = 21,
INVALID_PARAMETERS = 22,
INVALID_PARAMETERS_MISSING_URL = 23,
INVALID_PARAMETERS_MISSING_METHOD = 24,
INVALID_PARAMETERS_INVALID_METHOD = 25,
// Bridge Resource Cache Storage
LIGHT_ID_NOT_FOUND = 41,
SCHEDULE_ID_NOT_FOUND = 42,
GROUP_ID_NOT_FOUND = 43,
INVALID_DATA = 44,
// Pushlinking
PUSHLINK_NO_CONNECTION = 60,
PUSHLINK_TIME_LIMIT_REACHED = 61,
PUSHLINK_NO_LOCAL_BRIDGE = 62,
// Unsupported
UNSUPPORTED_IN_THIS_VERSION = 80,
// Domain objects
INVALID_DOMAIN_RESOURCE = 90,
INVALID_DOMAIN_RESOURCE_ARGUMENT = 91,
UNSUPPORTED_DOMAIN_RESOURCE_ARGUMENT = 92,
CLIP_ERROR = 100
} CLErrorCode;
/**
General purpose NSError derived object that is used for SDK errors
Enum of error codes identifies error types
*/
@interface PHError : NSError
@end
在對象 - 樣本項目中,他們比較枚舉的錯誤代碼是這樣的:
我的SWIFT代碼看起來是這樣的我得到以下錯誤:
我發現這個問題:Equality on Objective-C typedef enum in Swift
但它不適合我。我已經嘗試過...
error.code.value = PUSHLINK_NO_CONNECTION.value
error.code = PUSHLINK_NO_CONNECTION.value
error.code = .PUSHLINK_NO_CONNECTION
...
沒有什麼工作:(