0

I try to get clear of OptionSetType Protocol and I have some basic questions.
1) Does the options is an Array type or a Set type?
2) Can I access each element of options using for...in loop or for loop
thanks in advance

let options: NSDirectoryEnumerationOptions = [.SkipsHiddenFiles, .SkipsPackageDescendants, .SkipsSubdirectoryDescendants]
Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382
CocoaUser
  • 1,361
  • 1
  • 15
  • 30
  • About enumerating OptionSetType, compare [How do you enumerate OptionSetType in Swift 2?](http://stackoverflow.com/questions/32102936/how-do-you-enumerate-optionsettype-in-swift-2). – Martin R Mar 08 '16 at 09:03

1 Answers1

1

1) no

2) no

see this 'self explanatory' snippet

import Foundation

let options: NSDirectoryEnumerationOptions = [.SkipsHiddenFiles, .SkipsPackageDescendants, .SkipsSubdirectoryDescendants]

let res = options.rawValue == NSDirectoryEnumerationOptions.SkipsHiddenFiles.rawValue | NSDirectoryEnumerationOptions.SkipsPackageDescendants.rawValue | NSDirectoryEnumerationOptions.SkipsSubdirectoryDescendants.rawValue

print(res) // true
dump(options)
/*
▿ __C.NSDirectoryEnumerationOptions
  - rawValue: 7
*/

you can initialize it other way, with the same result

let options2 = NSDirectoryEnumerationOptions(rawValue: NSDirectoryEnumerationOptions.SkipsHiddenFiles.rawValue | NSDirectoryEnumerationOptions.SkipsPackageDescendants.rawValue | NSDirectoryEnumerationOptions.SkipsSubdirectoryDescendants.rawValue)

options2 == options // true
user3441734
  • 16,722
  • 2
  • 40
  • 59