Hi,
I’m trying to persist data in a App Group on Qt iOS app to share data between a
standalone app and app extension.
I have been reading on how to do it and apparently is dead simple ->
https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#//apple_ref/doc/uid/TP40014214-CH21-SW6
The problem is that it is not persisting data….
I’m starting to question the model I’m following in terms of code. I have my
Settings manager in C++. What I have done was to create a SettingsCocoa.mm file
that does what is below.
In a app session, the value is persisted but as soon as I start the app again,
the value is null.
As anyone experienced similar issues before? Any ideas would be highly
appreciated.
Thanks in advance.
Best regards,
Nuno
#include "Settings.h"
#import <Foundation/Foundation.h>
#include <QDebug>
static NSUserDefaults *defaults = nil;
QVariant Settings::sharedKey(QString key, const QVariant &defaultValue) const
{
if (defaults==nil)
defaults = [[NSUserDefaults alloc]
initWithSuiteName:@"group.com.acme.app"];
NSObject *value = [defaults valueForKey:key.toNSString()];
NSLog(@"get object: %@", value);
}
void Settings::setSharedKey(QString key, QVariant value)
{
if (defaults==nil)
defaults = [[NSUserDefaults alloc]
initWithSuiteName:@"group.com.acme.app"];
NSObject *object = [ISettingsManagerCocoaHelper variantToNSObject:value];
NSLog(@"set object: %@", object);
sharedKey(key, value);
[defaults synchronize];
}
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest