在uni-app中,plus.ios.invoke方法用于通过JavaScript直接调用Native Objective-C接口。该方法setObject:forKey:的作用是将一个对象存储到指定键中,用于数据的本地持久化。
try {
const stringValue = String(todoData.totalCount);
plus.ios.invoke(sharedDefaults, 'setObject:forKey:', stringValue, KEYS.TOTAL_COUNT);
plus.ios.invoke(sharedDefaults, 'synchronize');
console.log('使用字符串存储成功');
} catch (e) {
console.error('字符串存储失败:', e.message);
}
执行到plus.ios.invoke app直接终止没有任何报错。检查过参数类型确定没问题。
1 个回复
2***@qq.com (作者)
已经解决参考 官方配置改就行了