Skip to content

Commit 65e0a98

Browse files
authored
Add a global function to get storage instances (#5682)
* Add a global function to get storage instances * Fix missing header * Update CHANGELOG.md
1 parent 82cb49a commit 65e0a98

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

GoogleDataTransport/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# v6.2.0
22
- Added an API for arbitrary data persistence on storage instances.
3+
- Added an API for fetching storage instances specific to a target.
34

45
# v6.1.1
56
- Fixes writing event counts in a directory that doesn't yet exist. (#5549)

GoogleDataTransport/GDTCORLibrary/GDTCORRegistrar.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020
#import "GDTCORLibrary/Public/GDTCORConsoleLogger.h"
2121

22+
id<GDTCORStorageProtocol> _Nullable GDTCORStorageInstanceForTarget(GDTCORTarget target) {
23+
return [GDTCORRegistrar sharedInstance].targetToStorage[@(target)];
24+
}
25+
2226
@implementation GDTCORRegistrar {
2327
/** Backing ivar for targetToUploader property. */
2428
NSMutableDictionary<NSNumber *, id<GDTCORUploader>> *_targetToUploader;

GoogleDataTransport/GDTCORLibrary/Public/GDTCORStorageProtocol.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#import <Foundation/Foundation.h>
1818

1919
#import <GoogleDataTransport/GDTCORLifecycle.h>
20+
#import <GoogleDataTransport/GDTCORTargets.h>
2021

2122
@class GDTCOREvent;
2223

@@ -66,4 +67,12 @@ NS_ASSUME_NONNULL_BEGIN
6667

6768
@end
6869

70+
/** Retrieves the storage instance for the given target.
71+
*
72+
* @param target The target.
73+
* * @return The storage instance registered for the target, or nil if there is none.
74+
*/
75+
FOUNDATION_EXPORT
76+
id<GDTCORStorageProtocol> _Nullable GDTCORStorageInstanceForTarget(GDTCORTarget target);
77+
6978
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)