init
TypeScriptinitStringLiteral(stringLiteral: string): PreviewDeviceSwift declarationinit(stringLiteral: String)Creates an instance initialized to the given string value. - Parameter value: The value of the new instance.
struct · iOS 13.0+ · Deprecated in iOS 27.0 · SDK 27.1
struct PreviewDeviceA simulator device that runs a preview. Create a preview device by name, like "iPhone X", or by model number, like "iPad8,1". Use the device in a call to the ``View/previewDevice(_:)`` modifier to set a preview device that doesn't change when you change the run destination in Xcode: struct CircleImage_Previews: PreviewProvider { static var previews: some View { CircleImage() .previewDevice(PreviewDevice(rawValue: "iPad Pro (11-inch)")) } } You can get a list of supported preview device names by using the `xcrun` command in the Terminal app: % xcrun simctl list devicetypes Additionally, you can use the following values for macOS platform development: - "Mac" - "Mac Catalyst"
initStringLiteral(stringLiteral: string): PreviewDeviceSwift declarationinit(stringLiteral: String)Creates an instance initialized to the given string value. - Parameter value: The value of the new instance.
initRawValue(rawValue: string): PreviewDeviceSwift declarationinit(rawValue: String)Creates a new instance with the specified raw value. If there is no value of the type that corresponds with the specified raw value, this initializer returns `nil`. For example: enum PaperSize: String { case A4, A5, Letter, Legal } print(PaperSize(rawValue: "Legal")) // Prints "Optional(PaperSize.Legal)" print(PaperSize(rawValue: "Tabloid")) // Prints "nil" - Parameter rawValue: The raw value to use for the new instance.
getRawValue($self: PreviewDevice): stringSwift declarationlet rawValue: StringThe corresponding value of the raw type. A new instance initialized with `rawValue` will be equivalent to this instance. For example: enum PaperSize: String { case A4, A5, Letter, Legal } let selectedSize = PaperSize.Letter print(selectedSize.rawValue) // Prints "Letter" print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!) // Prints "true"
No declarations were skipped in this snapshot.