# GooglePlacesSwift Framework Reference

# AutocompletePlaceSuggestion

    struct AutocompletePlaceSuggestion

    extension AutocompletePlaceSuggestion : Copyable, CustomStringConvertible, Equatable, Escapable, Hashable, Sendable, SendableMetatype

This class represents a suggestion of a full query based on a partially typed string. \*/
- `


  ### [==(_:_:)](https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/AutocompletePlaceSuggestion#/s:17GooglePlacesSwift27AutocompletePlaceSuggestionV2eeoiySbAC_ACtFZ)


  ` 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: AutocompletePlaceSuggestion, rhs: AutocompletePlaceSuggestion) -> Bool

  #### Parameters

  |---|---|
  | ` lhs ` | A value to compare. |
  | ` rhs ` | Another value to compare. |

- `


  ### [attributedFullText](https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/AutocompletePlaceSuggestion#/s:17GooglePlacesSwift27AutocompletePlaceSuggestionV18attributedFullText10Foundation16AttributedStringVvp)


  ` The full description of the suggestion as a AttributedString.

  E.g., "Sydney Opera House, Sydney, New South Wales, Australia".

  Every text range that matches the user input has an `autocompleteMatchAttribute`. For example,
  you can make every match bold this way:

      let boldFont = UIFont.boldSystemFont(ofSize: UIFont.labelFontSize)

      var bolded: AttributedString = suggestion.attributedFullText
      guard let sourceAttributes = try? AttributeContainer(
        [.autocompleteMatch: ""],
        including: \.googlePlaces)
      else { return }

      let finalAttributes = sourceAttributes.merging(AttributeContainer([.font : boldFont]))

      bolded.replaceAttributes(sourceAttributes, with: finalAttributes)

      var Body: some View {
        Text(bolded)
      }

  #### Declaration

  Swift

      var attributedFullText: AttributedString { get }

- `


  ### [attributedPrimaryText](https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/AutocompletePlaceSuggestion#/s:17GooglePlacesSwift27AutocompletePlaceSuggestionV21attributedPrimaryText10Foundation16AttributedStringVvp)


  ` The main text of a suggestion as a AttributedString, usually the name of the place.

  E.g. "Sydney Opera House".

  Text ranges that match user input are have a `autocompleteMatchAttribute`,
  like `https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/AutocompletePlaceSuggestion.html#/s:17GooglePlacesSwift27AutocompletePlaceSuggestionV18attributedFullText10Foundation16AttributedStringVvp`.

  #### Declaration

  Swift

      var attributedPrimaryText: AttributedString { get }

- `


  ### [attributedSecondaryText](https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/AutocompletePlaceSuggestion#/s:17GooglePlacesSwift27AutocompletePlaceSuggestionV23attributedSecondaryText10Foundation16AttributedStringVSgvp)


  ` The secondary text of a suggestion as an AttributedString, usually the location of the place.

  E.g. "Sydney, New South Wales, Australia".

  Text ranges that match user input are have a `autocompleteMatchAttribute`, like
  `https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/AutocompletePlaceSuggestion.html#/s:17GooglePlacesSwift27AutocompletePlaceSuggestionV18attributedFullText10Foundation16AttributedStringVvp`.

  May be nil.

  #### Declaration

  Swift

      var attributedSecondaryText: AttributedString? { get }

- `


  ### [description](https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/AutocompletePlaceSuggestion#/s:17GooglePlacesSwift27AutocompletePlaceSuggestionV11descriptionSSvp)


  ` 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 }

- `


  ### [distance](https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/AutocompletePlaceSuggestion#/s:17GooglePlacesSwift27AutocompletePlaceSuggestionV8distance10Foundation11MeasurementVySo12NSUnitLengthCGSgvp)


  ` The straight line distance in meters between the origin and this suggestion.

  Only available if a valid origin is specified in the `https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/AutocompleteFilter.html` of the request.

  #### Declaration

  Swift

      var distance: Measurement<UnitLength>? { get }

- `


  ### [hash(into:)](https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/AutocompletePlaceSuggestion#/s:17GooglePlacesSwift27AutocompletePlaceSuggestionV4hash4intoys6HasherVz_tF)


  ` 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)

- `


  ### [hashValue](https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/AutocompletePlaceSuggestion#/s:17GooglePlacesSwift27AutocompletePlaceSuggestionV9hashValueSivp)


  ` 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 `https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/AutocompletePlaceSuggestion.html#/s:17GooglePlacesSwift27AutocompletePlaceSuggestionV4hash4intoys6HasherVz_tF` requirement instead. The compiler provides an implementation for `hashValue` for you.

  #### Declaration

  Swift

      var hashValue: Int { get }

- `


  ### [init(placeID:types:distance:primaryText:secondaryText:)](https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/AutocompletePlaceSuggestion#/s:17GooglePlacesSwift27AutocompletePlaceSuggestionV7placeID5types8distance11primaryText09secondaryL0ACSS_ShyAA0E4TypeVG10Foundation11MeasurementVySo12NSUnitLengthCGSgAL16AttributedStringVATSgtcfc)


  ` Instantiates an `AutocompletePlaceSuggestion` with the specified information.

  This initializer can be used for testing.

  The `AttributedString`s can be created using markdown to indicate substrings that contain the
  `autocompleteMatchAttribute`. eg:

      let key = AttributeScopes.GooglePlacesAttributes.AutocompleteMatchAttribute.markdownName
      let primaryText = try AttributedString(
        markdown: "^[Moun](\(key): '')tain ^[View](\(key): ''), CA",
        including: \.googlePlaces
        options: AttributedString.MarkdownParsingOptions(allowsExtendedAttributes: true))

  #### Declaration

  Swift

      init(placeID: String, types: Set<https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/PlaceType.html>, distance: Measurement<UnitLength>?, primaryText: AttributedString, secondaryText: AttributedString?)

  #### Parameters

  |---|---|
  | ` placeID ` | The id of the place. |
  | ` types ` | A set of `https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/PlaceType.html`s |
  | ` distance ` | The optional distance of the place. |
  | ` primaryText ` | The primary attributed string. |
  | ` secondaryText ` | The secondary attributed string. |

  #### Return Value

  An `AutocompletePlaceSuggestion` containing the specified information.
- `


  ### [init(placeID:types:distance:primaryText:secondaryText:)](https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/AutocompletePlaceSuggestion#/s:17GooglePlacesSwift27AutocompletePlaceSuggestionV7placeID5types8distance11primaryText09secondaryL0ACSS_ShyAA0E4TypeVG10Foundation11MeasurementVySo12NSUnitLengthCGSgSo18NSAttributedStringCATSgtcfc)


  ` Instantiates an `AutocompletePlaceSuggestion` with the specified information.

  This initializer can be used for testing.

  The `NSAttributedString`s contain sections with `https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Extensions/NSAttributedString/Key.html#/s:So21NSAttributedStringKeya17GooglePlacesSwiftE17autocompleteMatchABvpZ`
  to indicate substrings that contain the `autocompleteMatch` attribute.

  #### Declaration

  Swift

      init(placeID: String, types: Set<https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/PlaceType.html>, distance: Measurement<UnitLength>?, primaryText: NSAttributedString, secondaryText: NSAttributedString?)

  #### Parameters

  |---|---|
  | ` placeID ` | The id of the place. |
  | ` types ` | A set of `https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/PlaceType.html`s |
  | ` distance ` | The optional distance of the place. |
  | ` primaryText ` | The primary attributed string. |
  | ` secondaryText ` | The secondary attributed string. |

  #### Return Value

  An `AutocompletePlaceSuggestion` containing the specified information.
- `


  ### [legacyAttributedFullText](https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/AutocompletePlaceSuggestion#/s:17GooglePlacesSwift27AutocompletePlaceSuggestionV24legacyAttributedFullTextSo18NSAttributedStringCvp)


  ` The full description of the suggestion as a NSAttributedString.

  E.g., "Sydney Opera House, Sydney, New South Wales, Australia".

  Every text range that matches the user input has a `autocompleteMatch`. For
  example, you can make every match bold using enumerateAttribute:

        UIFont ///regularFont = [UIFont systemFontOfSize:[UIFont labelFontSize]];
        UIFont ///boldFont = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];

        NSMutableAttributedString ///bolded = [suggestion.attributedFullText mutableCopy];
        [bolded enumerateAttribute:autocompleteMatch
                           inRange:NSMakeRange(0, bolded.length)
                           options:0
                        usingBlock:^(id value, NSRange range, BOOL ///stop) {
                          UIFont ///font = (value == nil) ? regularFont : boldFont;
                          [bolded addAttribute:NSFontAttributeName value:font range:range];
                        }];

        label.attributedText = bolded;

  #### Declaration

  Swift

      var legacyAttributedFullText: NSAttributedString { get }

- `


  ### [legacyAttributedPrimaryText](https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/AutocompletePlaceSuggestion#/s:17GooglePlacesSwift27AutocompletePlaceSuggestionV27legacyAttributedPrimaryTextSo18NSAttributedStringCvp)


  ` The main text of a suggestion as a NSAttributedString, usually the name of the place.

  E.g. "Sydney Opera House".

  Text ranges that match user input are have a `autocompleteMatch`,
  like `https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/AutocompletePlaceSuggestion.html#/s:17GooglePlacesSwift27AutocompletePlaceSuggestionV18attributedFullText10Foundation16AttributedStringVvp`.

  #### Declaration

  Swift

      var legacyAttributedPrimaryText: NSAttributedString { get }

- `


  ### [legacyAttributedSecondaryText](https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/AutocompletePlaceSuggestion#/s:17GooglePlacesSwift27AutocompletePlaceSuggestionV29legacyAttributedSecondaryTextSo18NSAttributedStringCSgvp)


  ` The secondary text of a suggestion as a NSAttributedString, usually the location of the place.

  E.g. "Sydney, New South Wales, Australia".

  Text ranges that match user input are have a `autocompleteMatch`, like
  `https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/AutocompletePlaceSuggestion.html#/s:17GooglePlacesSwift27AutocompletePlaceSuggestionV18attributedFullText10Foundation16AttributedStringVvp`.

  May be nil.

  #### Declaration

  Swift

      var legacyAttributedSecondaryText: NSAttributedString? { get }

- `


  ### [placeID](https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/AutocompletePlaceSuggestion#/s:17GooglePlacesSwift27AutocompletePlaceSuggestionV7placeIDSSvp)


  ` A property representing the place ID of the suggestion.

  Suitable for use in a place details request.

  #### Declaration

  Swift

      var placeID: String { get }

- `


  ### [types](https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/AutocompletePlaceSuggestion#/s:17GooglePlacesSwift27AutocompletePlaceSuggestionV5typesShyAA0E4TypeVGvp)


  ` The types of this autocomplete result.

  Types are Strings, valid values are any types documented at
  <https://developers.google.com/places/ios-sdk/supported_types>.

  #### Declaration

  Swift

      var types: Set<https://developers.google.com/maps/documentation/places/ios-sdk/reference/swift/Structs/PlaceType.html> { get }