In the following example, I get no errors on write, but while reading, the data length is 0. Why can't I write to the shared container?
+ (UIImage *)read {
NSData *data = [NSData dataWithContentsOfFile:[self getPath]];
NSLog(@"Data length: %d", data.length);
UIImage *image = [UIImage imageWithContentsOfFile:[self getPath]];
NSLog(@"%@", image);
return image;
}
+ (void)write:(UIImage *)image {
NSString *pngFilePath = [self getPath];
NSData *data1 = [NSData dataWithData:UIImagePNGRepresentation(image)];
[data1 writeToFile:pngFilePath atomically:YES];
}
+ (NSString *)getPath {
NSURL *containerUrl = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:@"group.me.app"];
NSString *pngFilePath = [[containerUrl absoluteString] stringByAppendingPathComponent:@"current.png"];
NSLog(@"%@", pngFilePath);
return pngFilePath;
}