Thunk Thunk - 11 days ago 5x
iOS Question

How do I programmatically retreive the icloud container name?

To create a

I need to pass in the iCloud container name.

+ (void)createSessionInContainer:(NSString *)containerName
withTitle:(NSString *)title
completionHandler:(void (^)(GKGameSession *session, NSError *error))completionHandler;

Although I know where to find the container name in xCode by navigating to the Capabilities page, and although I know the default format is
I'm confused about how I programmatically find the container name.

I don't see it as an entry in the
file. While I could reconstruct it using the default format, what if I don't use the default container name? Do I really have to
the string?


To find the default container's ID programmatically:

#import <CloudKit/CloudKit.h>
CKContainer *defaultContainer = [CKContainer defaultContainer];
NSLog(@"default container ID: %@",defaultContainer.containerIdentifier);