GooglePlaces Framework Reference
Stay organized with collections
Save and categorize content based on your preferences.
GMSAutocompletePrediction
@interface GMSAutocompletePrediction : NSObject
This class represents a prediction of a full query based on a partially typed string.
-
The full description of the prediction as a NSAttributedString. E.g., “Sydney Opera House,
Sydney, New South Wales, Australia”.
Every text range that matches the user input has a kGMSAutocompleteMatchAttribute
. For
example, you can make every match bold using enumerateAttribute:
UIFont *regularFont = [UIFont systemFontOfSize:[UIFont labelFontSize]];
UIFont *boldFont = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
NSMutableAttributedString *bolded = [prediction.attributedFullText mutableCopy];
[bolded enumerateAttribute:kGMSAutocompleteMatchAttribute
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
@NSCopying var attributedFullText: NSAttributedString { get }
Objective-C
@property (nonatomic, copy, readonly) NSAttributedString *_Nonnull attributedFullText;
-
Declaration
Swift
@NSCopying var attributedPrimaryText: NSAttributedString { get }
Objective-C
@property (nonatomic, copy, readonly) NSAttributedString *_Nonnull attributedPrimaryText;
-
The secondary text of a prediction 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 kGMSAutocompleteMatchAttribute
, like
attributedFullText
.
May be nil.
Declaration
Swift
@NSCopying var attributedSecondaryText: NSAttributedString? { get }
Objective-C
@property (nonatomic, copy, readonly, nullable) NSAttributedString *attributedSecondaryText;
-
A property representing the place ID of the prediction, suitable for use in a place details
request.
Declaration
Swift
var placeID: String { get }
Objective-C
@property (nonatomic, copy, readonly) NSString *_Nonnull placeID;
-
Declaration
Swift
var types: [String] { get }
Objective-C
@property (nonatomic, copy, readonly) NSArray<NSString *> *_Nonnull types;
-
The straight line distance in meters between the origin and this prediction if a valid origin is
specified in the GMSAutocompleteFilter
of the request.
Declaration
Swift
var distanceMeters: NSNumber? { get }
Objective-C
@property (nonatomic, readonly, nullable) NSNumber *distanceMeters;
-
Initializer is not available.
Declaration
Objective-C
- (nonnull instancetype)init;
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\u003eGMSAutocompletePrediction\u003c/code\u003e objects represent predicted search queries based on partial user input.\u003c/p\u003e\n"],["\u003cp\u003ePredictions include attributed text for the full description, primary text (place name), and secondary text (location).\u003c/p\u003e\n"],["\u003cp\u003eEach prediction provides a \u003ccode\u003eplaceID\u003c/code\u003e for detailed place information requests and an array of \u003ccode\u003etypes\u003c/code\u003e describing the result.\u003c/p\u003e\n"],["\u003cp\u003eOptionally, \u003ccode\u003edistanceMeters\u003c/code\u003e indicates the distance from the origin specified in the request's filter.\u003c/p\u003e\n"]]],["`GMSAutocompletePrediction` offers details about a predicted query based on partial input. It provides `attributedFullText`, `attributedPrimaryText`, and `attributedSecondaryText` as formatted strings, with matching text highlighted via `kGMSAutocompleteMatchAttribute`. Key properties include `placeID` for place details, `types` for result classifications, and `distanceMeters` for distance if requested. It also demonstrates how to highlight matched text in `attributedFullText`. Lastly the `init` method is unavailable.\n"],null,["# GooglePlaces Framework Reference\n\nGMSAutocompletePrediction\n=========================\n\n @interface GMSAutocompletePrediction : NSObject\n\nThis class represents a prediction of a full query based on a partially typed string.\n- `\n ``\n ``\n `\n\n ### [attributedFullText](#/c:objc(cs)GMSAutocompletePrediction(py)attributedFullText)\n\n `\n ` \n The full description of the prediction as a NSAttributedString. E.g., \"Sydney Opera House,\n Sydney, New South Wales, Australia\".\n\n Every text range that matches the user input has a [kGMSAutocompleteMatchAttribute](../Constants/kGMSAutocompleteMatchAttribute.html). For\n example, you can make every match bold using enumerateAttribute: \n\n ```\n UIFont *regularFont = [UIFont systemFontOfSize:[UIFont labelFontSize]];\n UIFont *boldFont = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];\n\n NSMutableAttributedString *bolded = [prediction.attributedFullText mutableCopy];\n [bolded enumerateAttribute:kGMSAutocompleteMatchAttribute\n inRange:NSMakeRange(0, bolded.length)\n options:0\n usingBlock:^(id value, NSRange range, BOOL *stop) {\n UIFont *font = (value == nil) ? regularFont : boldFont;\n [bolded addAttribute:NSFontAttributeName value:font range:range];\n }];\n\n label.attributedText = bolded;\n \n ```\n\n \u003cbr /\u003e\n\n #### Declaration\n\n Swift \n\n @NSCopying var attributedFullText: NSAttributedString { get }\n\n Objective-C \n\n @property (nonatomic, copy, readonly) NSAttributedString *_Nonnull attributedFullText;\n\n- `\n ``\n ``\n `\n\n ### [attributedPrimaryText](#/c:objc(cs)GMSAutocompletePrediction(py)attributedPrimaryText)\n\n `\n ` \n The main text of a prediction as a NSAttributedString, usually the name of the place.\n E.g. \"Sydney Opera House\".\n\n Text ranges that match user input are have a [kGMSAutocompleteMatchAttribute](../Constants/kGMSAutocompleteMatchAttribute.html),\n like [attributedFullText](../Classes/GMSAutocompletePrediction.html#/c:objc(cs)GMSAutocompletePrediction(py)attributedFullText). \n\n #### Declaration\n\n Swift \n\n @NSCopying var attributedPrimaryText: NSAttributedString { get }\n\n Objective-C \n\n @property (nonatomic, copy, readonly) NSAttributedString *_Nonnull attributedPrimaryText;\n\n- `\n ``\n ``\n `\n\n ### [attributedSecondaryText](#/c:objc(cs)GMSAutocompletePrediction(py)attributedSecondaryText)\n\n `\n ` \n The secondary text of a prediction as a NSAttributedString, usually the location of the place.\n E.g. \"Sydney, New South Wales, Australia\".\n\n Text ranges that match user input are have a [kGMSAutocompleteMatchAttribute](../Constants/kGMSAutocompleteMatchAttribute.html), like\n [attributedFullText](../Classes/GMSAutocompletePrediction.html#/c:objc(cs)GMSAutocompletePrediction(py)attributedFullText).\n\n May be nil. \n\n #### Declaration\n\n Swift \n\n @NSCopying var attributedSecondaryText: NSAttributedString? { get }\n\n Objective-C \n\n @property (nonatomic, copy, readonly, nullable) NSAttributedString *attributedSecondaryText;\n\n- `\n ``\n ``\n `\n\n ### [placeID](#/c:objc(cs)GMSAutocompletePrediction(py)placeID)\n\n `\n ` \n A property representing the place ID of the prediction, suitable for use in a place details\n request. \n\n #### Declaration\n\n Swift \n\n var placeID: String { get }\n\n Objective-C \n\n @property (nonatomic, copy, readonly) NSString *_Nonnull placeID;\n\n- `\n ``\n ``\n `\n\n ### [types](#/c:objc(cs)GMSAutocompletePrediction(py)types)\n\n `\n ` \n The types of this autocomplete result. Types are NSStrings, valid values are any types\n documented at \u003chttps://developers.google.com/places/ios-sdk/supported_types\u003e. \n\n #### Declaration\n\n Swift \n\n var types: [String] { get }\n\n Objective-C \n\n @property (nonatomic, copy, readonly) NSArray\u003cNSString *\u003e *_Nonnull types;\n\n- `\n ``\n ``\n `\n\n ### [distanceMeters](#/c:objc(cs)GMSAutocompletePrediction(py)distanceMeters)\n\n `\n ` \n The straight line distance in meters between the origin and this prediction if a valid origin is\n specified in the [GMSAutocompleteFilter](../Classes/GMSAutocompleteFilter.html) of the request. \n\n #### Declaration\n\n Swift \n\n var distanceMeters: NSNumber? { get }\n\n Objective-C \n\n @property (nonatomic, readonly, nullable) NSNumber *distanceMeters;\n\n- `\n ``\n ``\n `\n\n ### [-init](#/c:objc(cs)GMSAutocompletePrediction(im)init)\n\n `\n ` \n Unavailable \n Initializer is not available. \n\n #### Declaration\n\n Objective-C \n\n - (nonnull instancetype)init;"]]