gpt4 book ai didi

react-native - React Native - 在调用 multiSet 时抛出异常 '-[NSNull length]: unrecognized selector sent to instance 0x1e6c059b0'

转载 作者:行者123 更新时间:2023-12-03 16:40:06 29 4
gpt4 key购买 nike

我在应用程序加载后几秒钟收到此错误(但有时在几分钟或几次下载后并不总是如此)。我需要解决这个问题。
如果需要更多细节和/或编辑 - 请告诉我,我会制作它们。

异常“-[NSNull 长度]:发送到实例 0x1e6c059b0”的无法识别的选择器在使用参数调用目标 AsyncLocalStorage 上的 multiSet 时被抛出(
(
(
"@Ye-Music:songs",
“”
)
),
483
)

Screenshot of the error

带有 AsyncStorage 的功能:

allSongs = () => {
console.log('hello function!');
fetch(URL + "/SongsList", {
body: null, //// sending null because its a view from SQL db
method: "POST",
headers: {
Accept: 'application/json',
"Content-type": "application/json; charset=UTF-8"
}
})
.then(res => { return res.json()})
.then((songsResult) => {
AsyncStorage.setItem("@Ye-Music:songs", songsResult.d);
})
.catch(err => {
console.error(err);
});
};


包.json
"dependencies": {
"@expo/samples": "2.1.1",
"expo": "29.0.0",
"react": "16.3.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-29.0.0.tar.gz",
"react-native-elements": "^0.19.1",
"react-native-material-cards": "^1.0.9",
"react-native-music-control": "^0.7.3",
"react-native-music-player-service": "^0.1.4-beta",
"react-native-search-header": "^0.3.0",
"react-native-sound": "^0.10.9",
"react-native-track-player": "^0.2.5",
"react-navigation": "^2.9.3"
},

最佳答案

调用 AsyncStorage 时,需要定义该值。如果不是,您将收到您遇到的错误。

错误处理逻辑(对于未定义的情况)可能是最好的方法。

if(songsResult && songsResult.d) {
AsyncStorage.setItem("@Ye-Music:songs", songsResult.d);
} else {
// handle error case here
}

关于react-native - React Native - 在调用 multiSet 时抛出异常 '-[NSNull length]: unrecognized selector sent to instance 0x1e6c059b0',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53552121/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com