Stay organized with collections
Save and categorize content based on your preferences.
GARFuture
Futures in ARCore
Futures represent the eventual completion of an asynchronous operation. A future has one of three states, GARFutureState, which can be obtained with GARFuture.state:
GARFutureStatePending - The operation is still pending. The result of the operation isn't available yet and any associated callback hasn't yet been invoked.
GARFutureStateDone - The operation is complete, and a result is available.
There are two ways of obtaining results from a GARFuture:
Polling a Future
When the GARFuture is created, its GARFutureState is set to GARFutureStatePending. You may poll the future using GARFuture.state to query the state of the asynchronous operation. When its state is GARFutureStateDone, you can obtain the operation's result.
Using a completion handler to obtain Future results
The operation's result can be reported via a completionHandler. When providing a completionHandler, ARCore will invoke the given block when the operation is complete, unless the future has been cancelled using cancel (GARFuture). This completionHandler will be called on the Main thread.
Cancelling a Future
You can try to cancel a GARFuture by calling cancel (GARFuture). Due to multi-threading, it is possible that the cancel operation is not successful. The return value indicates if the cancellation was successful.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-14 UTC."],[[["\u003cp\u003eGARFuture objects in ARCore represent the results of asynchronous operations, with states indicating pending, done, or cancelled.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can obtain results from a GARFuture by polling its state or by providing a completion handler to be invoked upon completion.\u003c/p\u003e\n"],["\u003cp\u003eA GARFuture can be cancelled using the \u003ccode\u003ecancel\u003c/code\u003e method, preventing the completion handler (if any) from being called.\u003c/p\u003e\n"],["\u003cp\u003eCancellation success is not guaranteed due to multi-threading, and the return value of the \u003ccode\u003ecancel\u003c/code\u003e method indicates whether it was successful.\u003c/p\u003e\n"],["\u003cp\u003eGARFuture has several subclasses like GARCreateAnchorOnRooftopFuture, GARCreateAnchorOnTerrainFuture, GARHostCloudAnchorFuture, GARResolveCloudAnchorFuture, and GARVPSAvailabilityFuture, indicating its role in various ARCore operations.\u003c/p\u003e\n"]]],[],null,["# GARFuture Class Reference\n\nGARFuture\n=========\n\n### Futures in ARCore\n\nFutures represent the eventual completion of an asynchronous operation. A future has one of three states, `GARFutureState`, which can be obtained with [GARFuture.state](/ar/reference/ios/interface/GARFuture#state):\n\n\n- [GARFutureStatePending](/ar/reference/ios/group/GARFutureState#garfuturestatepending) - The operation is still pending. The result of the operation isn't available yet and any associated callback hasn't yet been invoked.\n- [GARFutureStateDone](/ar/reference/ios/group/GARFutureState#garfuturestatedone) - The operation is complete, and a result is available.\n- [GARFutureStateCancelled](/ar/reference/ios/group/GARFutureState#garfuturestatecancelled) - The operation has been cancelled.\n\n\u003cbr /\u003e\n\nA [GARFuture](/ar/reference/ios/interface/GARFuture#interface_g_a_r_future) starts in the [GARFutureStatePending](/ar/reference/ios/group/GARFutureState#garfuturestatepending) state and transitions to [GARFutureStateDone](/ar/reference/ios/group/GARFutureState#garfuturestatedone) upon completion. If the future is cancelled using [cancel (GARFuture)](/ar/reference/ios/interface/GARFuture#cancel), then its state may become [GARFutureStateCancelled](/ar/reference/ios/group/GARFutureState#garfuturestatecancelled) (see [cancelling a future](/ar/reference/ios/interface/GARFuture-1future#cancelling-a-future) for caveats).\n\n### Obtaining results from a Future\n\nThere are two ways of obtaining results from a [GARFuture](/ar/reference/ios/interface/GARFuture#interface_g_a_r_future):\n\n### Polling a Future\n\nWhen the [GARFuture](/ar/reference/ios/interface/GARFuture#interface_g_a_r_future) is created, its `GARFutureState` is set to [GARFutureStatePending](/ar/reference/ios/group/GARFutureState#garfuturestatepending). You may poll the future using [GARFuture.state](/ar/reference/ios/interface/GARFuture#state) to query the state of the asynchronous operation. When its state is [GARFutureStateDone](/ar/reference/ios/group/GARFutureState#garfuturestatedone), you can obtain the operation's result.\n\n### Using a completion handler to obtain Future results\n\nThe operation's result can be reported via a `completionHandler`. When providing a `completionHandler`, ARCore will invoke the given block when the operation is complete, unless the future has been cancelled using [cancel (GARFuture)](/ar/reference/ios/interface/GARFuture#cancel). This `completionHandler` will be called on the Main thread.\n\n### Cancelling a Future\n\nYou can try to cancel a [GARFuture](/ar/reference/ios/interface/GARFuture#interface_g_a_r_future) by calling [cancel (GARFuture)](/ar/reference/ios/interface/GARFuture#cancel). Due to multi-threading, it is possible that the cancel operation is not successful. The return value indicates if the cancellation was successful.\n\nIf the cancellation is successful, then any [associated completion handler](/ar/reference/ios/interface/GARFuture-1future#using-a-completion-handler-to-obtain-future-results) will never be called.\n\nSummary\n-------\n\n### Inheritance\n\nInherits from: `NSObject` \nDirect Known Subclasses: [`GARCreateAnchorOnRooftopFuture`](/ar/reference/ios/interface/GARCreateAnchorOnRooftopFuture), [`GARCreateAnchorOnTerrainFuture`](/ar/reference/ios/interface/GARCreateAnchorOnTerrainFuture), [`GARHostCloudAnchorFuture`](/ar/reference/ios/interface/GARHostCloudAnchorFuture), [`GARResolveCloudAnchorFuture`](/ar/reference/ios/interface/GARResolveCloudAnchorFuture), [`GARVPSAvailabilityFuture`](/ar/reference/ios/interface/GARVPSAvailabilityFuture)\n\n| ### Properties ||\n|-----------------|---------------------------------------------------------------------------------------------------|\n| [state](#state) | [GARFutureState](/ar/reference/ios/group/GARFutureState#garfuturestate) The current future state. |\n\n| ### Public methods ||\n|-------------------|-----------------------------------------------------------|\n| [cancel](#cancel) | `BOOL` Cancels the async operation if it's still pending. |\n\nProperties\n----------\n\n### state\n\n```transact-sql\n@property(nonatomic, readonly) /ar/reference/ios/group/GARFutureState#garfuturestate /ar/reference/ios/interface/GARFuture#state;\n``` \nThe current future state.\n\nPublic methods\n--------------\n\n### cancel\n\n```text\n- (BOOL)cancel \n``` \nCancels the async operation if it's still pending.\n\nIf the operation was cancelled by this invocation, this method returns true and the callback (if any) will never be invoked."]]