FIRFirestore.mm 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "FIRFirestore+Internal.h"
  17. #include <memory>
  18. #include <string>
  19. #include <utility>
  20. #import "FIRFirestoreSettings+Internal.h"
  21. #import "FIRTransactionOptions+Internal.h"
  22. #import "FIRTransactionOptions.h"
  23. #import "FirebaseCore/Extension/FIRAppInternal.h"
  24. #import "FirebaseCore/Extension/FIRComponentContainer.h"
  25. #import "FirebaseCore/Extension/FIRComponentType.h"
  26. #import "Firestore/Source/API/FIRCollectionReference+Internal.h"
  27. #import "Firestore/Source/API/FIRDocumentReference+Internal.h"
  28. #import "Firestore/Source/API/FIRListenerRegistration+Internal.h"
  29. #import "Firestore/Source/API/FIRLoadBundleTask+Internal.h"
  30. #import "Firestore/Source/API/FIRQuery+Internal.h"
  31. #import "Firestore/Source/API/FIRTransaction+Internal.h"
  32. #import "Firestore/Source/API/FIRWriteBatch+Internal.h"
  33. #import "Firestore/Source/API/FSTFirestoreComponent.h"
  34. #import "Firestore/Source/API/FSTUserDataReader.h"
  35. #include "Firestore/core/src/api/collection_reference.h"
  36. #include "Firestore/core/src/api/document_reference.h"
  37. #include "Firestore/core/src/api/firestore.h"
  38. #include "Firestore/core/src/api/write_batch.h"
  39. #include "Firestore/core/src/core/database_info.h"
  40. #include "Firestore/core/src/core/event_listener.h"
  41. #include "Firestore/core/src/core/transaction.h"
  42. #include "Firestore/core/src/credentials/credentials_provider.h"
  43. #include "Firestore/core/src/model/database_id.h"
  44. #include "Firestore/core/src/remote/firebase_metadata_provider.h"
  45. #include "Firestore/core/src/util/async_queue.h"
  46. #include "Firestore/core/src/util/byte_stream_apple.h"
  47. #include "Firestore/core/src/util/config.h"
  48. #include "Firestore/core/src/util/empty.h"
  49. #include "Firestore/core/src/util/error_apple.h"
  50. #include "Firestore/core/src/util/exception.h"
  51. #include "Firestore/core/src/util/exception_apple.h"
  52. #include "Firestore/core/src/util/executor_libdispatch.h"
  53. #include "Firestore/core/src/util/hard_assert.h"
  54. #include "Firestore/core/src/util/log.h"
  55. #include "Firestore/core/src/util/status.h"
  56. #include "Firestore/core/src/util/statusor.h"
  57. #include "Firestore/core/src/util/string_apple.h"
  58. #include "absl/memory/memory.h"
  59. using firebase::firestore::api::DocumentReference;
  60. using firebase::firestore::api::Firestore;
  61. using firebase::firestore::api::ListenerRegistration;
  62. using firebase::firestore::core::EventListener;
  63. using firebase::firestore::credentials::AuthCredentialsProvider;
  64. using firebase::firestore::model::DatabaseId;
  65. using firebase::firestore::remote::FirebaseMetadataProvider;
  66. using firebase::firestore::util::AsyncQueue;
  67. using firebase::firestore::util::ByteStreamApple;
  68. using firebase::firestore::util::Empty;
  69. using firebase::firestore::util::Executor;
  70. using firebase::firestore::util::ExecutorLibdispatch;
  71. using firebase::firestore::util::LogSetLevel;
  72. using firebase::firestore::util::MakeCallback;
  73. using firebase::firestore::util::MakeNSError;
  74. using firebase::firestore::util::MakeNSString;
  75. using firebase::firestore::util::MakeString;
  76. using firebase::firestore::util::ObjcThrowHandler;
  77. using firebase::firestore::util::SetThrowHandler;
  78. using firebase::firestore::util::Status;
  79. using firebase::firestore::util::StatusOr;
  80. using firebase::firestore::util::ThrowIllegalState;
  81. using firebase::firestore::util::ThrowInvalidArgument;
  82. using firebase::firestore::util::kLogLevelDebug;
  83. using firebase::firestore::util::kLogLevelNotice;
  84. using firebase::firestore::util::StreamReadResult;
  85. using UserUpdateBlock = id _Nullable (^)(FIRTransaction *, NSError **);
  86. using UserTransactionCompletion = void (^)(id _Nullable, NSError *_Nullable);
  87. NS_ASSUME_NONNULL_BEGIN
  88. #pragma mark - FIRFirestore
  89. @interface FIRFirestore ()
  90. @property(nonatomic, strong, readonly) FSTUserDataReader *dataReader;
  91. @end
  92. @implementation FIRFirestore {
  93. std::shared_ptr<Firestore> _firestore;
  94. FIRFirestoreSettings *_settings;
  95. __weak id<FSTFirestoreInstanceRegistry> _registry;
  96. }
  97. + (void)initialize {
  98. if (self == [FIRFirestore class]) {
  99. SetThrowHandler(ObjcThrowHandler);
  100. Firestore::SetClientLanguage("gl-objc/");
  101. }
  102. }
  103. + (instancetype)firestore {
  104. FIRApp *app = [FIRApp defaultApp];
  105. if (!app) {
  106. ThrowIllegalState("Failed to get FirebaseApp instance. Please call FirebaseApp.configure() "
  107. "before using Firestore");
  108. }
  109. return [self firestoreForApp:app database:MakeNSString(DatabaseId::kDefault)];
  110. }
  111. + (instancetype)firestoreForApp:(FIRApp *)app {
  112. return [self firestoreForApp:app database:MakeNSString(DatabaseId::kDefault)];
  113. }
  114. // TODO(b/62410906): make this public
  115. + (instancetype)firestoreForApp:(FIRApp *)app database:(NSString *)database {
  116. if (!app) {
  117. ThrowInvalidArgument("FirebaseApp instance may not be nil. Use FirebaseApp.app() if you'd like "
  118. "to use the default FirebaseApp instance.");
  119. }
  120. if (!database) {
  121. ThrowInvalidArgument("Database identifier may not be nil. Use '%s' if you want the default "
  122. "database",
  123. DatabaseId::kDefault);
  124. }
  125. id<FSTFirestoreMultiDBProvider> provider =
  126. FIR_COMPONENT(FSTFirestoreMultiDBProvider, app.container);
  127. return [provider firestoreForDatabase:database];
  128. }
  129. - (instancetype)initWithDatabaseID:(model::DatabaseId)databaseID
  130. persistenceKey:(std::string)persistenceKey
  131. authCredentialsProvider:
  132. (std::shared_ptr<credentials::AuthCredentialsProvider>)authCredentialsProvider
  133. appCheckCredentialsProvider:
  134. (std::shared_ptr<credentials::AppCheckCredentialsProvider>)appCheckCredentialsProvider
  135. workerQueue:(std::shared_ptr<AsyncQueue>)workerQueue
  136. firebaseMetadataProvider:
  137. (std::unique_ptr<FirebaseMetadataProvider>)firebaseMetadataProvider
  138. firebaseApp:(FIRApp *)app
  139. instanceRegistry:(nullable id<FSTFirestoreInstanceRegistry>)registry {
  140. if (self = [super init]) {
  141. _firestore = std::make_shared<Firestore>(
  142. std::move(databaseID), std::move(persistenceKey), std::move(authCredentialsProvider),
  143. std::move(appCheckCredentialsProvider), std::move(workerQueue),
  144. std::move(firebaseMetadataProvider), (__bridge void *)self);
  145. _app = app;
  146. _registry = registry;
  147. FSTPreConverterBlock block = ^id _Nullable(id _Nullable input) {
  148. if ([input isKindOfClass:[FIRDocumentReference class]]) {
  149. auto documentReference = (FIRDocumentReference *)input;
  150. return [[FSTDocumentKeyReference alloc] initWithKey:documentReference.key
  151. databaseID:documentReference.firestore.databaseID];
  152. } else {
  153. return input;
  154. }
  155. };
  156. _dataReader = [[FSTUserDataReader alloc] initWithDatabaseID:_firestore->database_id()
  157. preConverter:block];
  158. // Use the property setter so the default settings get plumbed into _firestoreClient.
  159. self.settings = [[FIRFirestoreSettings alloc] init];
  160. }
  161. return self;
  162. }
  163. - (FIRFirestoreSettings *)settings {
  164. // Disallow mutation of our internal settings
  165. return [_settings copy];
  166. }
  167. - (void)setSettings:(FIRFirestoreSettings *)settings {
  168. if (![settings isEqual:_settings]) {
  169. _settings = settings;
  170. _firestore->set_settings([settings internalSettings]);
  171. #if HAVE_LIBDISPATCH
  172. std::unique_ptr<Executor> user_executor =
  173. absl::make_unique<ExecutorLibdispatch>(settings.dispatchQueue);
  174. #else
  175. // It's possible to build without libdispatch on macOS for testing purposes.
  176. // In this case, avoid breaking the build.
  177. std::unique_ptr<Executor> user_executor =
  178. Executor::CreateSerial("com.google.firebase.firestore.user");
  179. #endif // HAVE_LIBDISPATCH
  180. _firestore->set_user_executor(std::move(user_executor));
  181. }
  182. }
  183. - (void)setIndexConfigurationFromJSON:(NSString *)json
  184. completion:(nullable void (^)(NSError *_Nullable error))completion {
  185. _firestore->SetIndexConfiguration(MakeString(json), MakeCallback(completion));
  186. }
  187. - (void)setIndexConfigurationFromStream:(NSInputStream *)stream
  188. completion:(nullable void (^)(NSError *_Nullable error))completion {
  189. auto input = absl::make_unique<ByteStreamApple>(stream);
  190. auto callback = MakeCallback(completion);
  191. std::string json;
  192. bool eof = false;
  193. while (!eof) {
  194. StreamReadResult result = input->Read(1024ul);
  195. if (!result.ok()) {
  196. callback(result.status());
  197. return;
  198. }
  199. eof = result.eof();
  200. json.append(std::move(result).ValueOrDie());
  201. }
  202. _firestore->SetIndexConfiguration(json, callback);
  203. }
  204. - (FIRCollectionReference *)collectionWithPath:(NSString *)collectionPath {
  205. if (!collectionPath) {
  206. ThrowInvalidArgument("Collection path cannot be nil.");
  207. }
  208. if (!collectionPath.length) {
  209. ThrowInvalidArgument("Collection path cannot be empty.");
  210. }
  211. if ([collectionPath containsString:@"//"]) {
  212. ThrowInvalidArgument("Invalid path (%s). Paths must not contain // in them.", collectionPath);
  213. }
  214. return [[FIRCollectionReference alloc]
  215. initWithReference:_firestore->GetCollection(MakeString(collectionPath))];
  216. }
  217. - (FIRDocumentReference *)documentWithPath:(NSString *)documentPath {
  218. if (!documentPath) {
  219. ThrowInvalidArgument("Document path cannot be nil.");
  220. }
  221. if (!documentPath.length) {
  222. ThrowInvalidArgument("Document path cannot be empty.");
  223. }
  224. if ([documentPath containsString:@"//"]) {
  225. ThrowInvalidArgument("Invalid path (%s). Paths must not contain // in them.", documentPath);
  226. }
  227. DocumentReference documentReference = _firestore->GetDocument(MakeString(documentPath));
  228. return [[FIRDocumentReference alloc] initWithReference:std::move(documentReference)];
  229. }
  230. - (FIRQuery *)collectionGroupWithID:(NSString *)collectionID {
  231. if (!collectionID) {
  232. ThrowInvalidArgument("Collection ID cannot be nil.");
  233. }
  234. if (!collectionID.length) {
  235. ThrowInvalidArgument("Collection ID cannot be empty.");
  236. }
  237. if ([collectionID containsString:@"/"]) {
  238. ThrowInvalidArgument("Invalid collection ID (%s). Collection IDs must not contain / in them.",
  239. collectionID);
  240. }
  241. auto query = _firestore->GetCollectionGroup(MakeString(collectionID));
  242. return [[FIRQuery alloc] initWithQuery:std::move(query) firestore:_firestore];
  243. }
  244. - (FIRWriteBatch *)batch {
  245. return [FIRWriteBatch writeBatchWithDataReader:self.dataReader writeBatch:_firestore->GetBatch()];
  246. }
  247. - (void)runTransactionWithOptions:(FIRTransactionOptions *_Nullable)options
  248. block:(UserUpdateBlock)updateBlock
  249. dispatchQueue:(dispatch_queue_t)queue
  250. completion:(UserTransactionCompletion)completion {
  251. if (!updateBlock) {
  252. ThrowInvalidArgument("Transaction block cannot be nil.");
  253. }
  254. if (!completion) {
  255. ThrowInvalidArgument("Transaction completion block cannot be nil.");
  256. }
  257. class TransactionResult {
  258. public:
  259. TransactionResult(FIRFirestore *firestore,
  260. UserUpdateBlock update_block,
  261. dispatch_queue_t queue,
  262. UserTransactionCompletion completion)
  263. : firestore_(firestore),
  264. user_update_block_(update_block),
  265. queue_(queue),
  266. user_completion_(completion) {
  267. }
  268. void RunUpdateBlock(std::shared_ptr<core::Transaction> internalTransaction,
  269. core::TransactionResultCallback internalCallback) {
  270. dispatch_async(queue_, ^{
  271. auto transaction = [FIRTransaction transactionWithInternalTransaction:internalTransaction
  272. firestore:firestore_];
  273. NSError *_Nullable error = nil;
  274. user_result_ = user_update_block_(transaction, &error);
  275. // If the user set an error, disregard the result.
  276. if (error) {
  277. // If the error is a user error, set flag to not retry the transaction.
  278. if (error.domain != FIRFirestoreErrorDomain) {
  279. internalTransaction->MarkPermanentlyFailed();
  280. }
  281. internalCallback(Status::FromNSError(error));
  282. } else {
  283. internalCallback(Status::OK());
  284. }
  285. });
  286. }
  287. void HandleFinalStatus(const Status &status) {
  288. if (!status.ok()) {
  289. user_completion_(nil, MakeNSError(status));
  290. return;
  291. }
  292. user_completion_(user_result_, nil);
  293. }
  294. private:
  295. FIRFirestore *firestore_;
  296. UserUpdateBlock user_update_block_;
  297. dispatch_queue_t queue_;
  298. UserTransactionCompletion user_completion_;
  299. id _Nullable user_result_;
  300. };
  301. auto result_capture = std::make_shared<TransactionResult>(self, updateBlock, queue, completion);
  302. // Wrap the user-supplied updateBlock in a core C++ compatible callback. Wrap the result of the
  303. // updateBlock invocation up in a TransactionResult for tunneling through the internals of the
  304. // system.
  305. auto internalUpdateBlock = [result_capture](
  306. std::shared_ptr<core::Transaction> internalTransaction,
  307. core::TransactionResultCallback internalCallback) {
  308. result_capture->RunUpdateBlock(internalTransaction, internalCallback);
  309. };
  310. // Unpacks the TransactionResult value and calls the user completion handler.
  311. //
  312. // PORTING NOTE: Other platforms where the user return value is internally representable don't
  313. // need this wrapper.
  314. auto objcTranslator = [result_capture](const Status &status) {
  315. result_capture->HandleFinalStatus(status);
  316. };
  317. int max_attempts = [FIRTransactionOptions defaultMaxAttempts];
  318. if (options) {
  319. // Note: The cast of `maxAttempts` from `NSInteger` to `int` is safe (i.e. lossless) because
  320. // `FIRTransactionOptions` does not allow values greater than `INT32_MAX` to be set.
  321. max_attempts = static_cast<int>(options.maxAttempts);
  322. }
  323. _firestore->RunTransaction(std::move(internalUpdateBlock), std::move(objcTranslator),
  324. max_attempts);
  325. }
  326. - (void)runTransactionWithBlock:(id _Nullable (^)(FIRTransaction *, NSError **error))updateBlock
  327. completion:
  328. (void (^)(id _Nullable result, NSError *_Nullable error))completion {
  329. [self runTransactionWithOptions:nil block:updateBlock completion:completion];
  330. }
  331. - (void)runTransactionWithOptions:(FIRTransactionOptions *_Nullable)options
  332. block:(id _Nullable (^)(FIRTransaction *, NSError **))updateBlock
  333. completion:
  334. (void (^)(id _Nullable result, NSError *_Nullable error))completion {
  335. static dispatch_queue_t transactionDispatchQueue;
  336. static dispatch_once_t onceToken;
  337. dispatch_once(&onceToken, ^{
  338. transactionDispatchQueue = dispatch_queue_create("com.google.firebase.firestore.transaction",
  339. DISPATCH_QUEUE_CONCURRENT);
  340. });
  341. [self runTransactionWithOptions:options
  342. block:updateBlock
  343. dispatchQueue:transactionDispatchQueue
  344. completion:completion];
  345. }
  346. + (void)enableLogging:(BOOL)logging {
  347. LogSetLevel(logging ? kLogLevelDebug : kLogLevelNotice);
  348. }
  349. - (void)useEmulatorWithHost:(NSString *)host port:(NSInteger)port {
  350. if (!host.length) {
  351. ThrowInvalidArgument("Host cannot be nil or empty.");
  352. }
  353. if (!_settings.isUsingDefaultHost) {
  354. LOG_WARN("Overriding previously-set host value: %@", _settings.host);
  355. }
  356. // Use a new settings so the new settings are automatically plumbed
  357. // to the underlying Firestore objects.
  358. NSString *settingsHost = [NSString stringWithFormat:@"%@:%li", host, (long)port];
  359. FIRFirestoreSettings *newSettings = [_settings copy];
  360. newSettings.host = settingsHost;
  361. self.settings = newSettings;
  362. }
  363. - (void)enableNetworkWithCompletion:(nullable void (^)(NSError *_Nullable error))completion {
  364. _firestore->EnableNetwork(MakeCallback(completion));
  365. }
  366. - (void)disableNetworkWithCompletion:(nullable void (^)(NSError *_Nullable))completion {
  367. _firestore->DisableNetwork(MakeCallback(completion));
  368. }
  369. - (void)clearPersistenceWithCompletion:(nullable void (^)(NSError *_Nullable error))completion {
  370. _firestore->ClearPersistence(MakeCallback(completion));
  371. }
  372. - (void)waitForPendingWritesWithCompletion:(void (^)(NSError *_Nullable error))completion {
  373. _firestore->WaitForPendingWrites(MakeCallback(completion));
  374. }
  375. - (void)terminateWithCompletion:(nullable void (^)(NSError *_Nullable error))completion {
  376. id<FSTFirestoreInstanceRegistry> strongRegistry = _registry;
  377. if (strongRegistry) {
  378. [strongRegistry
  379. removeInstanceWithDatabase:MakeNSString(_firestore->database_id().database_id())];
  380. }
  381. [self terminateInternalWithCompletion:completion];
  382. }
  383. - (id<FIRListenerRegistration>)addSnapshotsInSyncListener:(void (^)(void))listener {
  384. std::unique_ptr<core::EventListener<Empty>> eventListener =
  385. core::EventListener<Empty>::Create([listener](const StatusOr<Empty> &) { listener(); });
  386. std::unique_ptr<ListenerRegistration> result =
  387. _firestore->AddSnapshotsInSyncListener(std::move(eventListener));
  388. return [[FSTListenerRegistration alloc] initWithRegistration:std::move(result)];
  389. }
  390. - (FIRLoadBundleTask *)loadBundle:(nonnull NSData *)bundleData {
  391. auto stream = absl::make_unique<ByteStreamApple>([[NSInputStream alloc] initWithData:bundleData]);
  392. return [self loadBundleStream:[[NSInputStream alloc] initWithData:bundleData] completion:nil];
  393. }
  394. - (FIRLoadBundleTask *)loadBundle:(NSData *)bundleData
  395. completion:(nullable void (^)(FIRLoadBundleTaskProgress *_Nullable progress,
  396. NSError *_Nullable error))completion {
  397. return [self loadBundleStream:[[NSInputStream alloc] initWithData:bundleData]
  398. completion:completion];
  399. }
  400. - (FIRLoadBundleTask *)loadBundleStream:(NSInputStream *)bundleStream {
  401. return [self loadBundleStream:bundleStream completion:nil];
  402. }
  403. - (FIRLoadBundleTask *)loadBundleStream:(NSInputStream *)bundleStream
  404. completion:
  405. (nullable void (^)(FIRLoadBundleTaskProgress *_Nullable progress,
  406. NSError *_Nullable error))completion {
  407. auto stream = absl::make_unique<ByteStreamApple>(bundleStream);
  408. std::shared_ptr<api::LoadBundleTask> task = _firestore->LoadBundle(std::move(stream));
  409. auto callback = [completion](api::LoadBundleTaskProgress progress) {
  410. if (!completion) {
  411. return;
  412. }
  413. // Ignoring `kInProgress` because we are setting up for completion callback.
  414. if (progress.state() == api::LoadBundleTaskState::kSuccess) {
  415. completion([[FIRLoadBundleTaskProgress alloc] initWithInternal:progress], nil);
  416. } else if (progress.state() == api::LoadBundleTaskState::kError) {
  417. NSError *error = nil;
  418. if (!progress.error_status().ok()) {
  419. LOG_WARN("Progress set to Error, but error_status() is ok()");
  420. error = MakeNSError(firebase::firestore::Error::kErrorUnknown,
  421. "Loading bundle failed with unknown error");
  422. } else {
  423. error = MakeNSError(progress.error_status());
  424. }
  425. completion([[FIRLoadBundleTaskProgress alloc] initWithInternal:progress], error);
  426. }
  427. };
  428. task->SetLastObserver(callback);
  429. return [[FIRLoadBundleTask alloc] initWithTask:task];
  430. }
  431. - (void)getQueryNamed:(NSString *)name completion:(void (^)(FIRQuery *_Nullable query))completion {
  432. auto firestore = _firestore;
  433. auto callback = [completion, firestore](core::Query query, bool found) {
  434. if (!completion) {
  435. return;
  436. }
  437. if (found) {
  438. FIRQuery *firQuery = [[FIRQuery alloc] initWithQuery:std::move(query) firestore:firestore];
  439. completion(firQuery);
  440. } else {
  441. completion(nil);
  442. }
  443. };
  444. _firestore->GetNamedQuery(MakeString(name), callback);
  445. }
  446. @end
  447. @implementation FIRFirestore (Internal)
  448. - (std::shared_ptr<Firestore>)wrapped {
  449. return _firestore;
  450. }
  451. - (const std::shared_ptr<AsyncQueue> &)workerQueue {
  452. return _firestore->worker_queue();
  453. }
  454. - (const DatabaseId &)databaseID {
  455. return _firestore->database_id();
  456. }
  457. + (FIRFirestore *)recoverFromFirestore:(std::shared_ptr<Firestore>)firestore {
  458. return (__bridge FIRFirestore *)firestore->extension();
  459. }
  460. - (void)terminateInternalWithCompletion:(nullable void (^)(NSError *_Nullable error))completion {
  461. _firestore->Terminate(MakeCallback(completion));
  462. }
  463. @end
  464. NS_ASSUME_NONNULL_END