Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想使用一个数组来设置枚举的组合
所以我有一个带有几个整数的 NSArray。
例如我想这样做:
[self setCachePolicy:ASIFallbackToCacheIfLoadFailsCachePolicy|ASIOnlyLoadIfNotCachedCachePolicy];
但是有一个 NSArray !
一个主意?
这应该是它。
NSArray *myArray = @[ @(ASIFallbackToCacheIfLoadFailsCachePolicy), @(ASIOnlyLoadIfNotCachedCachePolicy) ]; int combo = 0; for (NSNumber *box in myArray) { combo |= [box intValue]; } [self setCachePolicy:combo];