我正在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');
我无法理解崩溃原因,因为应用程序在调试模式下运行正常。
答案 0 :(得分:1)
只需重申@Waleed在对他的问题的评论中提到的内容。要解决此问题,您需要确保仅将字符串传递给Array
(
[0] => sssss
[1] => %folklore%
[2] => %folklore%
[3] => %folklore%
[4] => %folklore%
[5] => %folklore%
)
。
我无法解释为什么此错误仅出现在iOS版本中。我还测试了一个Android发布版本,当我传递一个整数时,它运行良好。