2015-07-19 54 views
0

我在objc定义了以下枚举:商店NS_OPTIONS在迅速字典

typedef NS_OPTIONS(NSInteger, RKRequestMethod) { 
    RKRequestMethodGET   = 1 << 0, 
    RKRequestMethodPOST   = 1 << 1, 
    // ... 
}; 

所以在objc,我可以通过拳击与@()整数值做到这一点:在迅速

NSDictionary *dict = @{ @"s": @(RKRequestMethodGET) } 

现在,我想在一本字典中存储这样一个枚举:

var v = [String: AnyObject]() 
v = ["s": RKRequestMethod.POST 
v = ["s": NSNumber(char: RKRequestMethod.POST)] 
v = ["s": NSNumber(unsignedChar: RKRequestMethod.POST)] 
v = ["s": NSNumber(short: RKRequestMethod.POST)] 
v = ["s": NSNumber(unsignedShort: RKRequestMethod.POST)] 
// There are approx 10 more of these and I tried them all 

回答

1

我弄明白了。它其实很简单:

v = ["s": RKRequestMethod.Any.rawValue]