GooglePlacesSwift Framework Reference
Stay organized with collections
Save and categorize content based on your preferences.
Photo
struct Photo
extension Photo : Copyable, CustomStringConvertible, Equatable, Escapable, Hashable, Sendable
The metadata corresponding to a single photo associated with a place.
-
Returns a Boolean value indicating whether two values are equal.
Equality is the inverse of inequality. For any values a
and b
,
a == b
implies that a != b
is false
.
Declaration
Swift
static func == (lhs: Photo, rhs: Photo) -> Bool
Parameters
lhs
|
|
rhs
|
Another value to compare.
|
-
The data provider attribution string for this photo.
These are provided as a NSAttributedString, which may contain hyperlinks to the website of
each provider.
In general, these must be shown to the user if data from this PlacePhotoMetadata
is shown,
as described in the Places SDK Terms of Service.
Declaration
Swift
var attributions: AttributedString? { get }
-
-
A textual representation of this instance.
Calling this property directly is discouraged. Instead, convert an
instance of any type to a string by using the String(describing:)
initializer. This initializer works with any type, and uses the custom
description
property for types that conform to
CustomStringConvertible
:
struct Point: CustomStringConvertible {
let x: Int, y: Int
var description: String {
return "(\(x), \(y))"
}
}
let p = Point(x: 21, y: 30)
let s = String(describing: p)
print(s)
// Prints "(21, 30)"
The conversion of p
to a string in the assignment to s
uses the
Point
type’s description
property.
Declaration
Swift
var description: String { get }
-
Hashes the essential components of this value by feeding them into the
given hasher.
Implement this method to conform to the Hashable
protocol. The
components used for hashing must be the same as the components compared
in your type’s ==
operator implementation. Call hasher.combine(_:)
with each of these components.
Important
In your implementation of hash(into:)
,
don’t call finalize()
on the hasher
instance provided,
or replace it with a different instance.
Doing so may become a compile-time error in the future.
Declaration
Swift
func hash(into hasher: inout Hasher)
-
The hash value.
Hash values are not guaranteed to be equal across different executions of
your program. Do not save hash values to use during a future execution.
Important
hashValue
is deprecated as a
Hashable
requirement. To
conform to
Hashable
, implement the
hash(into:)
requirement instead.
The compiler provides an implementation for
hashValue
for you.
Declaration
Swift
var hashValue: Int { get }
-
Instantiates a Photo
with the specified information.
Photo
s can be gotten from a Place
object. This initializer can be used for
testing.
Declaration
Swift
init(maxSize: CGSize, attributions: AttributedString? = nil, authorAttributions: [AuthorAttribution] = [])
Parameters
maxSize
|
The maximum pixel size in which this photo is available.
|
attributions
|
The data provider attribution string for this photo.
|
authorAttributions
|
The optional author attributions for this photo.
|
Return Value
A Photo
containing the specified information.
-
Instantiates a Photo
with the specified information.
Photo
s can be gotten from a Place
object. This initializer can be used for
testing.
Declaration
Swift
init(maxSize: CGSize, attributions: NSAttributedString?, authorAttributions: [AuthorAttribution] = [])
Parameters
maxSize
|
The maximum pixel size in which this photo is available.
|
attributions
|
The data provider attribution string for this photo.
|
authorAttributions
|
The optional author attributions for this photo.
|
Return Value
A Photo
containing the specified information.
-
The data provider attribution string for this photo.
These are provided as a NSAttributedString, which may contain hyperlinks to the website of
each provider.
In general, these must be shown to the user if data from this PlacePhotoMetadata
is shown,
as described in the Places SDK Terms of Service.
Declaration
Swift
var legacyAttributions: NSAttributedString? { get }
-
The maximum pixel size in which this photo is available.
Declaration
Swift
var maxSize: CGSize { get }
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-27 UTC.
[null,null,["Last updated 2025-08-27 UTC."],[[["\u003cp\u003e\u003ccode\u003ePhoto\u003c/code\u003e stores metadata for a single photo associated with a place, including attributions, author information, and maximum size.\u003c/p\u003e\n"],["\u003cp\u003eIt conforms to \u003ccode\u003eCustomStringConvertible\u003c/code\u003e, \u003ccode\u003eEquatable\u003c/code\u003e, and \u003ccode\u003eHashable\u003c/code\u003e for describing, comparing, and uniquely identifying photos.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eattributions\u003c/code\u003e property provides an attributed string detailing data provider credits, which should be displayed to users.\u003c/p\u003e\n"],["\u003cp\u003ePhotos can be instantiated for testing purposes using initializers that accept size, attributions, and author details.\u003c/p\u003e\n"]]],["The `Photo` struct represents metadata for a photo associated with a place. Key properties include `maxSize`, representing the maximum available pixel size, `attributions` (and `legacyAttributions`) for data provider attribution strings that might have hyperlinks, and `authorAttributions` containing attribution information of the photo's author. `Photo` instances are equatable via `==`, hashable with `hash(into:)`, and can be described textually. They can be initiated using the `init` function.\n"],null,["# GooglePlacesSwift Framework Reference\n\nPhoto\n=====\n\n struct Photo\n\n extension Photo : Copyable, CustomStringConvertible, Equatable, Escapable, Hashable, Sendable\n\nThe metadata corresponding to a single photo associated with a place.\n- `\n ``\n ``\n `\n\n ### [==(_:_:)](#/s:17GooglePlacesSwift5PhotoV2eeoiySbAC_ACtFZ)\n\n `\n ` \n Returns a Boolean value indicating whether two values are equal.\n\n Equality is the inverse of inequality. For any values `a` and `b`,\n `a == b` implies that `a != b` is `false`. \n\n #### Declaration\n\n Swift \n\n static func == (lhs: Photo, rhs: Photo) -\u003e Bool\n\n #### Parameters\n\n |-------------|---------------------------|\n | ` `*lhs*` ` | A value to compare. |\n | ` `*rhs*` ` | Another value to compare. |\n\n- `\n ``\n ``\n `\n\n ### [attributions](#/s:17GooglePlacesSwift5PhotoV12attributions10Foundation16AttributedStringVSgvp)\n\n `\n ` \n The data provider attribution string for this photo.\n\n These are provided as a NSAttributedString, which may contain hyperlinks to the website of\n each provider.\n\n In general, these must be shown to the user if data from this `PlacePhotoMetadata` is shown,\n as described in the Places SDK Terms of Service. \n\n #### Declaration\n\n Swift \n\n var attributions: AttributedString? { get }\n\n- `\n ``\n ``\n `\n\n ### [authorAttributions](#/s:17GooglePlacesSwift5PhotoV18authorAttributionsSayAA17AuthorAttributionVGvp)\n\n `\n ` \n\n #### Declaration\n\n Swift \n\n var authorAttributions: [../Structs/AuthorAttribution.html] { get }\n\n- `\n ``\n ``\n `\n\n ### [description](#/s:17GooglePlacesSwift5PhotoV11descriptionSSvp)\n\n `\n ` \n A textual representation of this instance.\n\n Calling this property directly is discouraged. Instead, convert an\n instance of any type to a string by using the `String(describing:)`\n initializer. This initializer works with any type, and uses the custom\n `description` property for types that conform to\n `CustomStringConvertible`: \n\n struct Point: CustomStringConvertible {\n let x: Int, y: Int\n\n var description: String {\n return \"(\\(x), \\(y))\"\n }\n }\n\n let p = Point(x: 21, y: 30)\n let s = String(describing: p)\n print(s)\n // Prints \"(21, 30)\"\n\n The conversion of `p` to a string in the assignment to `s` uses the\n `Point` type's `description` property. \n\n #### Declaration\n\n Swift \n\n var description: String { get }\n\n- `\n ``\n ``\n `\n\n ### [hash(into:)](#/s:17GooglePlacesSwift5PhotoV4hash4intoys6HasherVz_tF)\n\n `\n ` \n Hashes the essential components of this value by feeding them into the\n given hasher.\n\n Implement this method to conform to the `Hashable` protocol. The\n components used for hashing must be the same as the components compared\n in your type's `==` operator implementation. Call `hasher.combine(_:)`\n with each of these components. \n Important\n\n In your implementation of `hash(into:)`,\n don't call `finalize()` on the `hasher` instance provided,\n or replace it with a different instance.\n Doing so may become a compile-time error in the future. \n\n #### Declaration\n\n Swift \n\n func hash(into hasher: inout Hasher)\n\n- `\n ``\n ``\n `\n\n ### [hashValue](#/s:17GooglePlacesSwift5PhotoV9hashValueSivp)\n\n `\n ` \n The hash value.\n\n Hash values are not guaranteed to be equal across different executions of\n your program. Do not save hash values to use during a future execution. \n Important\n `hashValue` is deprecated as a `Hashable` requirement. To conform to `Hashable`, implement the [hash(into:)](../Structs/Photo.html#/s:17GooglePlacesSwift5PhotoV4hash4intoys6HasherVz_tF) requirement instead. The compiler provides an implementation for `hashValue` for you. \n\n #### Declaration\n\n Swift \n\n var hashValue: Int { get }\n\n- `\n ``\n ``\n `\n\n ### [init(maxSize:attributions:authorAttributions:)](#/s:17GooglePlacesSwift5PhotoV7maxSize12attributions18authorAttributionsACSo6CGSizeV_10Foundation16AttributedStringVSgSayAA17AuthorAttributionVGtcfc)\n\n `\n ` \n Instantiates a `Photo` with the specified information.\n\n `Photo`s can be gotten from a [Place](../Structs/Place.html) object. This initializer can be used for\n testing. \n\n #### Declaration\n\n Swift \n\n init(maxSize: CGSize, attributions: AttributedString? = nil, authorAttributions: [../Structs/AuthorAttribution.html] = [])\n\n #### Parameters\n\n |----------------------------|----------------------------------------------------------|\n | ` `*maxSize*` ` | The maximum pixel size in which this photo is available. |\n | ` `*attributions*` ` | The data provider attribution string for this photo. |\n | ` `*authorAttributions*` ` | The optional author attributions for this photo. |\n\n #### Return Value\n\n A `Photo` containing the specified information.\n- `\n ``\n ``\n `\n\n ### [init(maxSize:attributions:authorAttributions:)](#/s:17GooglePlacesSwift5PhotoV7maxSize12attributions18authorAttributionsACSo6CGSizeV_So18NSAttributedStringCSgSayAA17AuthorAttributionVGtcfc)\n\n `\n ` \n Instantiates a `Photo` with the specified information.\n\n `Photo`s can be gotten from a [Place](../Structs/Place.html) object. This initializer can be used for\n testing. \n\n #### Declaration\n\n Swift \n\n init(maxSize: CGSize, attributions: NSAttributedString?, authorAttributions: [../Structs/AuthorAttribution.html] = [])\n\n #### Parameters\n\n |----------------------------|----------------------------------------------------------|\n | ` `*maxSize*` ` | The maximum pixel size in which this photo is available. |\n | ` `*attributions*` ` | The data provider attribution string for this photo. |\n | ` `*authorAttributions*` ` | The optional author attributions for this photo. |\n\n #### Return Value\n\n A `Photo` containing the specified information.\n- `\n ``\n ``\n `\n\n ### [legacyAttributions](#/s:17GooglePlacesSwift5PhotoV18legacyAttributionsSo18NSAttributedStringCSgvp)\n\n `\n ` \n The data provider attribution string for this photo.\n\n These are provided as a NSAttributedString, which may contain hyperlinks to the website of\n each provider.\n\n In general, these must be shown to the user if data from this `PlacePhotoMetadata` is shown,\n as described in the Places SDK Terms of Service. \n\n #### Declaration\n\n Swift \n\n var legacyAttributions: NSAttributedString? { get }\n\n- `\n ``\n ``\n `\n\n ### [maxSize](#/s:17GooglePlacesSwift5PhotoV7maxSizeSo6CGSizeVvp)\n\n `\n ` \n The maximum pixel size in which this photo is available. \n\n #### Declaration\n\n Swift \n\n var maxSize: CGSize { get }"]]