我正在开发一款React Native应用程序,适用于iOS。该应用程序在模拟器上运行良好。我尝试在iPad上测试该应用程序,在调试模式下它可以正常工作,但是当我在iPad上以发布模式运行应用程序时,在点击按钮时会出现异常。异常信息为:
Terminating app due to uncaught exception 'RCTFatalException: Exception '-[__NSCFNumber length]: unrecognized selector sent to instance 0x94fbee52df959691' was thrown while invoking multiSet on target RNCAsyncStorage with params (
(
(
"@TOS:deletedProjects",
1864
)
),
2573
导致此异常的代码是:
let projects = JSON.parse(await AsyncStorage.getItem('@TOS:projects'));
console.log('projects', projects);
let index = projects.findIndex(x => x.p_id === project.p_id);
console.log(projects, index);
projects.splice(index , 1);
console.log('projects', projects);
await AsyncStorage.setItem('@TOS:projects', JSON.stringify(projects));
// await AsyncStorage.setItem('@TOS:deletedProjects', JSON.stringify(project.p_id));
let deletedProjects = await AsyncStorage.getItem('@TOS:deletedProjects')
console.log("********** " + deletedProjects);
if(deletedProjects !== '' && deletedProjects !== null && deletedProjects !== undefined){
console.log('if have deleted projects');
let combined = '"' + deletedProjects + '"' + ',' + '"' + project.p_id + '"';
console.log('combined', combined);
await AsyncStorage.setItem('@TOS:deletedProjects', combined);
}else{
console.log('if no deleted projects');
await AsyncStorage.setItem('@TOS:deletedProjects', project.p_id);
}
console.log('in success');
我不明白应用程序为什么会崩溃,因为在调试模式下它完全正常运行。