Int
, as the RawValue
type.
あなた独自のオプションセットを作成する時、このイニシャライザを固定長整数、Int
などをRawValue
型として使って実装してください。
init(rawValue : Self.RawValue)
Availability
Technology
protocol OptionSet
You use the Option
protocol to represent bitset types, where individual bits represent members of a set. Adopting this protocol in your custom types lets you perform set-related operations such as membership tests, unions, and intersections on those types. What’s more, when implemented using specific criteria, adoption of this protocol requires no extra work on your part.
あなたは、Option
プロトコルを使ってビットセット型を表すことができます、そこにおいて個々のビットはセットのメンバを表します。この型をあなたのあつらえの型において採用することは、あなたにセット関連演算を行わせます、例えば、それらの型上での帰属テスト、合併、そして交叉など。おまけに、特定の基準を使って実装される時、このプロトコルの採用はあなたの方での余分な作業を必要としません。
When creating an option set, include a raw
property in your type declaration. For your type to automatically receive default implementations for set-related operations, the raw
property must be of a type that conforms to the Fixed
protocol, such as Int
or UInt8
. Next, create unique options as static properties of your custom type using unique powers of two (1, 2, 4, 8, 16, and so forth) for each individual property’s raw value so that each property can be represented by a single bit of the type’s raw value.
あるオプションセットを作成する場合は、raw
プロパティをあなたの型宣言に加えてください。あなたの型が自動的に省略時の実装をセット関連の演算に対して受け取るようにするには、raw
プロパティは、Fixed
プロトコルに準拠する型の1つでなければなりません、例えばInt
またはUInt8
など。次に、それぞれが特有なオプションをあなたのあつらえの型の静的プロパティとして作成してください、特有な2の冪(1、2、4、8、16、およびそれ以降)を各個別プロパティの生の値に対して使います、それで各プロパティはその型のもつ生の値からなるある単一ビットによって表されることができます。
For example, consider a custom type called Shipping
that is an option set of the possible ways to ship a customer’s purchase. Shipping
includes a raw
property of type Int
that stores the bit mask of available shipping options. The static members next
, second
, priority
, and standard
are unique, individual options.
例えば、Shipping
と呼ばれるあつらえの型を考えてください、それは顧客の購入品を出荷する可能な方法のオプションセットです。Shipping
は、型Int
のraw
プロパティを含みます、それは可能な出荷オプションのビットマスクを格納します。静的メンバnext
, second
、priority
、そしてstandard
は特有で、別個のオプションです。
Declare additional preconfigured option set values as static properties initialized with an array literal containing other option values. In the example, because the express
static property is assigned an array literal with the next
and second
options, it will contain those two elements.
追加のあらかじめ構成されるオプションセット値を、他のオプション値を含んでいる配列リテラルで初期化される静的プロパティとして宣言してください。例において、express
静的プロパティはnext
とsecond
オプションを持つ配列リテラルを割り当てられるので、それはそれら2つの要素を含みます。
When you need to create an instance of an option set, assign one of the type’s static members to your variable or constant. Alternatively, to create an option set instance with multiple members, assign an array literal with multiple static members of the option set. To create an empty instance, assign an empty array literal to your variable. あなたがあるオプションセットのインスタンスを作成する必要がある場合は、その型のもつ静的メンバの1つをあなたの変数または定数に割り当ててください。あるいはまた、複数のメンバをもつ1つのオプションセットインスタンスを作成するには、オプションセットの複数の静的メンバをもつ配列リテラルを割り当ててください。空のインスタンスを作成するには、空の配列リテラルをあなたの変数に割り当ててください。
Use set-related operations to check for membership and to add or remove members from an instance of your custom option set type. The following example shows how you can determine free shipping options based on a customer’s purchase price: セット関連演算を使って、帰属を確認したり、あなたのあつらえのオプションセット型のインスタンス由来のメンバの追加や削除を行ってください。以下の例は、どうやってあなたが顧客の購入品価格を基に無償出荷オプションを判定できるかを示します:
Int
, as the RawValue
type.
あなた独自のオプションセットを作成する時、このイニシャライザを固定長整数、Int
などをRawValue
型として使って実装してください。
init(rawValue : Self.RawValue)
associatedtype Element
AEAssessmentConfiguration.AutocorrectMode
ARConfiguration.FrameSemantics
ARConfiguration.SceneReconstruction
ARHitTestResult.ResultType
ARWorldTrackingConfiguration.PlaneDetection
ARSession.RunOptions
ARView.DebugOptions
ARView.EntityGestures
ARView.Environment.SceneUnderstanding.Options
ARView.RenderOptions
AU3DMixerRenderingFlags
AUGenericViewDisplayFlags
AUHostTransportStateFlags
AUParameterMIDIMappingFlags
AUScheduledAudioSliceFlags
AUSpatialMixerRenderingFlags
AVAssetReferenceRestrictions
AVAudioPlayerNodeBufferOptions
AVAudioSessionActivationOptions
AVAudioSession.CategoryOptions
AVAudioSession.InterruptionOptions
AVAudioSession.SetActiveOptions
AVAudioSpatializationFormats
AVCaption.Decoration
AVCaptureDevice.PrimaryConstituentDeviceRestrictedSwitchingBehaviorConditions
AVCaptureDevice.SystemPressureState.Factors
AVDelegatingPlaybackCoordinatorRateChangeOptions
AVDelegatingPlaybackCoordinatorSeekOptions
AVMovieWritingOptions
AVMusicSequenceLoadOptions
AVPlayer.HDRMode
AVPlayerInterstitialEvent.Restrictions
AVVariantPreferences
AXCopyMultipleAttributeOptions
AXMFiHearingDevice.Ear
AXMenuItemModifiers
AnchoringComponent.Target.Alignment
AnchoringComponent.Target.Classification
AnimationFillMode
ArchiveFlags
AttributedString.FormattingOptions
AttributedString.InterpolationOptions
AudioBytePacketTranslationFlags
AudioChannelBitmap
AudioChannelFlags
AudioComponentFlags
AudioComponentInstantiationOptions
AudioFileFlags
AudioFileRegionFlags
AudioFileStreamParseFlags
AudioFileStreamPropertyFlags
AudioFileStreamSeekFlags
AudioQueueProcessingTapFlags
AudioSettingsFlags
AudioTimeStampFlags
AudioUnitParameterOptions
AudioUnitRenderActionFlags
AuthorizationFlags
Axis.Set
BNNSFlags
BroadcastOptions
ByteCountFormatStyle.Units
CAAutoresizingMask
CACornerMask
CAEdgeAntialiasingMask
CAFFormatFlags
CAFRegionFlags
CBAttributePermissions
CBCentralManager.Feature
CBCharacteristicProperties
CFCalendarUnit
CFDataSearchFlags
CFFileSecurityClearOptions
CFGregorianUnitFlags
CFISO8601DateFormatOptions
CFNetServiceBrowserFlags
CFNetServiceRegisterFlags
CFNumberFormatterOptionFlags
CFPropertyListMutabilityOptions
CFRunLoopActivity
CFSocketCallBackType
CFStreamEventType
CFStringCompareFlags
CFStringTokenizerTokenType
CFURLBookmarkCreationOptions
CFURLBookmarkResolutionOptions
CFURLEnumeratorOptions
CFXMLParserOptions
CFXMLParserStatusCode
CGBitmapInfo
CGCaptureOptions
CGConfigureOption
CGDisplayChangeSummaryFlags
CGEventFilterMask
CGEventFlags
CGGradientDrawingOptions
CGPDFAccessPermissions
CGScreenUpdateOperation
CGWindowImageOption
CGWindowListOption
CKContainer.ApplicationPermissions
CKQuerySubscription.Options
CKRecordZone.Capabilities
CLKComplicationTimeTravelDirections
CMAttitudeReferenceFrame
CMBlockBuffer.Flags
CMFormatDescription.EqualityMask
CMFormatDescription.Extensions.Value.FontFace
CMFormatDescription.TimeCode.Flag
CMIOExtensionStream.DiscontinuityFlags
CMSSignedAttributes
CMSampleBuffer.Flags
CMTimeFlags
CPContentStyle
CPLimitableUserInterface
CPManeuverDisplayStyle
CPMapTemplate.PanDirection
CTFontCollectionCopyOptions
CTFontOptions
CTFontStylisticClass
CTFontSymbolicTraits
CTFontTableOptions
CTLineBoundsOptions
CTRunStatus
CTUnderlineStyle
CTUnderlineStyleModifiers
CVPixelBufferLockFlags
CVPixelBufferPoolFlushFlags
CVSMPTETimeFlags
CVTimeFlags
CVTimeStampFlags
CWCipherKeyFlags
CharacterControllerComponent.CollisionFlags
CollisionGroup
ContentShapeKinds
DatePickerComponents
DispatchIO.CloseFlags
DispatchIO.IntervalFlags
DispatchQueue.Attributes
DispatchSource.FileSystemEvent
DispatchSource.MachSendEvent
DispatchSource.MemoryPressureEvent
DispatchSource.ProcessEvent
DispatchSource.TimerFlags
DispatchWorkItemFlags
EAWiFiUnconfiguredAccessoryProperties
EKCalendarEventAvailabilityMask
EKEntityMask
ENActivityFlags
Edge.Set
EventModifiers
GKMeshGraphTriangulationMode
GestureMask
GraphicsContext.BlurOptions
GraphicsContext.ClipOptions
GraphicsContext.FilterOptions
GraphicsContext.GradientOptions
GraphicsContext.ShadowOptions
HKQuantitySeriesSampleQueryDescriptor.Options
HKQueryOptions
HKStatisticsOptions
HMHomeManagerAuthorizationStatus
HorizontalEdge.Set
INCallCapabilityOptions
INCallRecordTypeOptions
INCarSignalOptions
INDayOfWeekOptions
INMessageAttributeOptions
INPhotoAttributeOptions
INRideFeedbackTypeOptions
INShortcutAvailabilityOptions
INTemporalEventTriggerTypeOptions
IOSurfaceLockOptions
IOSurfacePurgeabilityState
IOUSBHostIsochronousTransactionOptions
IOUSBHostIsochronousTransferOptions
IOUSBHostObjectInitOptions
InlinePresentationIntent
JSONEncoder.OutputFormatting
LSAcceptanceFlags
LSHandlerOptions
LSItemInfoFlags
LSLaunchFlags
LSRequestedInfo
LSRolesMask
MIDIPerNoteManagementOptions
MIDIProgramChangeOptions
MKDirectionsTransportType
MKLocalSearchCompleter.ResultType
MKLocalSearch.ResultType
MLActionClassifier.VideoAugmentationOptions
MLCExecutionOptions
MLCGraphCompilationOptions
MLHandActionClassifier.VideoAugmentationOptions
MLHandPoseClassifier.ImageAugmentationOptions
MLImageClassifier.ImageAugmentationOptions
MLMediaSourceType
MLUpdateProgressEvent
MPMediaPlaylistAttribute
MPMediaType
MPMovieLoadState
MPMovieMediaTypeMask
MPSAccelerationStructureUsage
MPSAliasingStrategy
MPSCNNBatchNormalizationFlags
MPSCNNConvolutionGradientOption
MPSDeviceOptions
MPSKernelOptions
MPSMatrixRandomDistribution
MPSNNComparisonType
MPSNNConvolutionAccumulatorPrecisionOption
MPSNNPaddingMethod
MPSNNTrainingStyle
MPSRayMaskOptions
MTLAccelerationStructureInstanceOptions
MTLAccelerationStructureUsage
MTLBarrierScope
MTLBlitOption
MTLColorWriteMask
MTLCommandBufferErrorOption
MTLFunctionOptions
MTLIndirectCommandType
MTLIntersectionFunctionSignature
MTLPipelineOption
MTLRenderStages
MTLResourceOptions
MTLResourceUsage
MTLStoreActionOptions
MTLTextureUsage
MapInteractionModes
MatchedGeometryProperties
MusicSequenceFileFlags
MusicSequenceLoadFlags
MusicTokenRequestOptions
NFCISO15693RequestFlag
NFCISO15693ResponseFlag
NFCTagReaderSession.PollingOption
NLTagger.Options
NLTokenizer.Attributes
ProcessInfo.ActivityOptions
AlignmentOptions
NSAppleEventDescriptor.SendOptions
NSApplication.ActivationOptions
NSApplication.OcclusionState
NSApplication.PresentationOptions
NSAttributedString.EnumerationOptions
NSView.AutoresizingMask
NSBinarySearchingOptions
NSBitmapImageRep.Format
ByteCountFormatter.Units
NSCalendar.Options
NSCalendar.Unit
NSCell.HitResult
NSCell.StyleMask
NSSharingService.CloudKitOptions
NSCollectionView.ScrollPosition
NSColorPanel.Options
NSComparisonPredicate.Options
NSData.Base64DecodingOptions
NSData.Base64EncodingOptions
NSData.ReadingOptions
NSData.SearchOptions
NSData.WritingOptions
DateComponentsFormatter.ZeroFormattingBehavior
NSDatePicker.ElementFlags
NSDirectionalRectEdge
FileManager.DirectoryEnumerationOptions
DistributedNotificationCenter.Options
NSDragOperation
NSDraggingItemEnumerationOptions
NSEnumerationOptions
NSEvent.ButtonMask
NSEvent.EventTypeMask
NSEvent.ModifierFlags
NSEvent.Phase
NSEvent.SwipeTrackingOptions
NSFetchRequestResultType
NSFileCoordinator.ReadingOptions
NSFileCoordinator.WritingOptions
FileManager.ItemReplacementOptions
FileManager.UnmountOptions
NSFileProviderCreateItemOptions
NSFileProviderDeleteItemOptions
NSFileProviderDomain.TestingModes
NSFileProviderFetchContentsOptions
NSFileProviderFileSystemFlags
NSFileProviderItemCapabilities
NSFileProviderItemFields
NSFileProviderManager.DisconnectionOptions
NSFileProviderMaterializationFlags
NSFileProviderModifyItemOptions
NSFileVersion.AddingOptions
NSFileVersion.ReplacingOptions
FileWrapper.ReadingOptions
FileWrapper.WritingOptions
NSFontAssetRequest.Options
NSFontCollectionOptions
NSFontCollection.Visibility
NSFontPanel.ModeMask
NSFontDescriptor.SymbolicTraits
NSFontTraitMask
NSGradient.DrawingOptions
ISO8601DateFormatter.Options
NSItemProviderFileOptions
JSONSerialization.ReadingOptions
JSONSerialization.WritingOptions
NSKeyValueObservingOptions
NSLayoutConstraint.FormatOptions
NSLayoutManager.ControlCharacterAction
NSLayoutManager.GlyphProperty
NSLinguisticTagger.Options
NSMachPort.Options
NSRegularExpression.MatchingFlags
NSRegularExpression.MatchingOptions
MeasurementFormatter.UnitOptions
NSMediaLibraryBrowserController.Library
NSMenu.Properties
NetService.Options
NotificationQueue.NotificationCoalescing
NSOrderedCollectionDifferenceCalculationOptions
NSPDFPanel.Options
NSParagraphStyle.LineBreakStrategy
NSPasteboard.ContentsOptions
NSPasteboard.ReadingOptions
NSPasteboard.WritingOptions
NSPersistentCloudKitContainerSchemaInitializationOptions
PersonNameComponentsFormatter.Options
NSPointerFunctions.Options
NSPrintPanel.Options
PropertyListSerialization.MutabilityOptions
NSRegularExpression.Options
NSApplication.RemoteNotificationType
FileManager.SearchPathDomainMask
NSSnapshotEventType
NSSortOptions
NSSpringLoadingOptions
NSStatusItem.Behavior
Stream.Event
NSString.CompareOptions
NSString.DrawingOptions
NSString.EncodingConversionOptions
NSString.EnumerationOptions
NSTableColumn.ResizingOptions
NSTableView.AnimationOptions
NSTableView.GridLineStyle
NSTextCheckingResult.CheckingType
NSTextContentManager.EnumerationOptions
NSTextLayoutFragment.EnumerationOptions
NSTextLayoutManager.SegmentOptions
NSTextList.Options
NSTextSelectionNavigation.Modifier
NSTextStorageEditActions
NSTouch.Phase
NSTouch.TouchTypeMask
NSTrackingArea.Options
NSTypesetterControlCharacterAction
NSURL.BookmarkCreationOptions
NSURL.BookmarkResolutionOptions
NSUnderlineStyle
NSViewController.TransitionOptions
FileManager.VolumeEnumerationOptions
NSWindow.CollectionBehavior
NSApplication.WindowListOptions
NSWindow.NumberListOptions
NSWindow.OcclusionState
NSWindow.StyleMask
NSWorkspace.IconCreationOptions
NSWorkspace.LaunchOptions
NSXPCConnection.Options
NWBrowser.Result.Change.Flags
OSLogEnumerator.Options
PDFAreaOfInterest
PHASEPushStreamBufferOptions
PHASESpatialPipeline.Flags
PHAssetBurstSelectionType
PHAssetMediaSubtype
PHAssetSourceType
PHLivePhotoBadgeOptions
PKAddressField
PKMerchantCapability
PKRadioTechnology
PasteboardFlavorFlags
PasteboardSyncFlags
PinnedScrollableViews
QLThumbnailGenerator.Request.RepresentationTypes
RedactionReasons
SCNBillboardAxis
SCNColorMask
SCNDebugOptions
SCNPhysicsCollisionCategory
SCNetworkReachabilityFlags
SCPreferencesNotification
SKCloudServiceCapability
SKTileAdjacencyMask
SMPTETimeFlags
SafeAreaRegions
SceneView.Options
SecAccessControlCreateFlags
SecCSFlags
SecCodeSignatureFlags
SecCodeStatus
SecItemImportExportFlags
SecKeyImportExportFlags
SecKeyUsage
SecKeychainEventMask
SecKeychainPromptSelector
SecPadding
SecTrustOptionFlags
SecTrustSettingsKeyUsage
SessionAttributeBits
SessionCreationFlags
SpriteView.DebugOptions
SpriteView.Options
SubmitTriggers
TKSmartCardUserInteractionForPINOperation.Completion
TKSmartCardUserInteractionForSecurePINChange.Confirmation
TKSmartCardProtocol
TVContentItemImageTrait
TVTopShelfCarouselItem.MediaOptions
TVTopShelfItem.ImageTraits
UIAccessibilityTraits
UIAccessibility.HearingDeviceEar
UIAxis
UICloudSharingController.PermissionOptions
UICollectionView.ScrollPosition
UICollisionBehavior.Mode
UIControl.Event
UIControl.State
UIDataDetectorTypes
UIDirectionalRectEdge
UIDocumentBrowserAction.Availability
UIDocument.State
UIEvent.ButtonMask
UIFocusHeading
UIFontDescriptor.SymbolicTraits
UIGuidedAccessAccessibilityFeature
UIInterfaceOrientationMask
UIKeyModifierFlags
UIMenuElement.Attributes
UIMenu.Options
UIPopoverArrowDirection
UIPrinter.JobTypes
UIRectCorner
UIRectEdge
UIRemoteNotificationType
UIScrollTypeMask
UISwipeGestureRecognizer.Direction
UITableViewCell.StateMask
UITextDragOptions
UITouch.Properties
UIUserNotificationType
UIView.AnimationOptions
UIView.AutoresizingMask
UIView.KeyframeAnimationOptions
UNAuthorizationOptions
UNNotificationActionOptions
UNNotificationCategoryOptions
UNNotificationPresentationOptions
VTCompressionSessionOptionFlags
VTDecodeFrameFlags
VTDecodeInfoFlags
VTEncodeInfoFlags
VZMacAuxiliaryStorage.InitializationOptions
VerticalEdge.Set
WKAudiovisualMediaTypes
WKDataDetectorTypes
WKSwipeGestureRecognizerDirection
WebDragDestinationAction
WebDragSourceAction
XCTMeasureOptions.InvocationOptions
XCUIElement.KeyModifierFlags
XMLNode.Options
interface_event_t
vImage.Options
struct Set